跨进程点击treeview节点

来源:互联网 发布:生活用品 淘宝店 编辑:程序博客网 时间:2024/04/30 03:48

最近写VBA程序,点击treeview控件的节点,只能用windows的api函数mouse_event,但是window系统锁屏的时候,mouse_event函数会被屏蔽,在网上找了半天,找到代码注入的方法,但在VBA里createremotethread时候,被注入的进程会崩溃,具体原因不太清楚。 最后用C++试了下WM_LBUTTONDBLCLK,竟然有作用,而同样的代码在VBA无效....,下面是C++代码,测试有效


#include "stdafx.h"
#include  "windows.h" 
int _tmain(int argc, _TCHAR* argv[])
{
HWND hTree =(HWND)_ttoi(argv[1]);
::SetForegroundWindow(hTree);
::SetFocus(hTree);
    POINT pt={0};
    pt.x = _ttoi(argv[2]);
    pt.y = _ttoi(argv[3]);


::ClientToScreen(hTree,&pt);

::SetCursorPos(pt.x,pt.y);
::Sleep(500);
::PostMessage(hTree,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM((WORD)pt.x,(WORD)pt.y));
::PostMessage(hTree,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM((WORD)pt.x,(WORD)pt.y));
::PostMessage(hTree,WM_LBUTTONDBLCLK,MK_LBUTTON,MAKELPARAM((WORD)pt.x,(WORD)pt.y));


}








0 0
原创粉丝点击