SetWindowsHookEx() WM_KEYBOARD_LL not coming through with full screen RDC

前端 未结 2 741
长情又很酷
长情又很酷 2021-01-03 10:39

I\'m trying to do a away timer style thing like Skype. If the user is \'away\' for a period of time I\'ll trigger something. I have been using SetWindowsHookEx() with WM_KEY

相关标签:
2条回答
  • 2021-01-03 11:22

    Have a look at GetLastInputInfo(). Try calling that periodically.

    0 讨论(0)
  • 2021-01-03 11:24

    Yes. You'll not get keys pressed in remote desktop. I had this problem and only solution I found was this:

    Using FindWindow API always look to find RDP window, if you've detected that full-screen RDP window has been created you should do this:

    a) Unhook all hooks. b) Reset all hooks.

    So create a function which makes SetWindowHookEx API calls and call it SetHook and another one as UnHook function. Then re-call both of them anytime you find out user get into remote desktop.

    Now you can get keys pressed even inside remote desktop connection.

    I found my old code, I did something like this:

    Created a timer with 1 sec. Then

    std::string tmp;
    HWND hParent = ::FindWindow(TEXT("TSHELLHWND"), NULL);
    GetWindowString(hParent, tmp);
    
    ix = za.find(" - Remote Desktop");
    
    if (hParent != NULL && ix != string::npos)
    RestartHook();
    

    You also should have a global variable to set when you've restarted hook, otherwise all the time it will restart the hook. When window closed, you can reset that global variable.

    0 讨论(0)
提交回复
热议问题