How to send Ctrl/Shift/Alt + Key combinations to an application window? (via SendMessage)

后端 未结 5 628
日久生厌
日久生厌 2021-02-13 18:24

I can successfully send any single key message to an application, but I don\'t know how to send combinations of keys (like Ctrl+F12, Shift+

5条回答
  •  你的背包
    2021-02-13 19:02

    I already tried the method with GetKeyboardState and SetKeyboardState (preceded by attaching the window thread and ended with detaching from window thread). I doesn't work for combinations of keys like Ctrl+Something or combinations using Alt or Shift also. Control, Alt and Shift keys are not seen as pressed. It seems like the maximum you can get when the window is minimized is pressing individual keys using PostMessage with WM_KEYDOWN messages. Another thing I noticed is that if you Post WM_KEYDOWN and WM_KEYUP (for the same key) the key will be pressed twice. So only use WM_KEYDOWN one time. This is not an 100% accurate method but when window is minimized there are some limitations.

    The same situation happens when screen is locked.

提交回复
热议问题