使用SendMessage

时间:2016-09-04 18:48:29

标签: sendmessage

int VK_F_DOWN = GetVirtualKey('F', 0);
int VK_F_UP = GetVirtualKey('F', 1);
HWND hWnd = FindWindow(NULL,L"Calculator.exe");

SendMessage(hWnd, WM_KEYDOWN, toascii('F'), VK_F_DOWN);
SendMessage(hWnd, WM_KEYUP, toascii('F'), VK_F_UP);

它不适用于Calculator.exe,但是当我将hWnd更改为HWND(0xFFFF)时,它可以在我的visual studio上运行。 我也已经获得了非零hWnd。我在这里错过了什么?像权威或什么?

1 个答案:

答案 0 :(得分:0)

听起来像User Interface Privilege Isolation。正如Wikipedia文章所解释的那样,您可以在应用程序清单中请求所需的访问权限。

那就是说,你应该使用SendInput而不是SendMessage。请参阅one of Raymond Chen's blog entries on that point