Convert character to virtual key code

后端 未结 7 1422
说谎
说谎 2021-01-06 09:40

I have a string of values, and I want to simulate key press events in a window for each character.

I plan on sending WM_KEYDOWN, WM_CHAR, and WM_KEYUP events to the

相关标签:
7条回答
  • 2021-01-06 10:16

    Sending WM_KEYDOWN/UP is troublesome. The application itself already translates the WM_KEYDOWN message into WM_CHAR, using the state of the modifier keys (Shift, Alt, Ctrl) and the keyboard layout. Neither of which you can control, you'll get the wrong character, randomly.

    Just send WM_CHAR messages, set the wparam to the character code. No need to worry about lparam, few apps ever use it.

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