How can I deal with depressed Windows logo key when using `SendInput`?

后端 未结 3 1331
我寻月下人不归
我寻月下人不归 2020-12-19 20:22

My application synthesises keystrokes in other apps by using SendInput. This almost works, except that due to circumstances I cannot change, the left Windows ke

3条回答
  •  猫巷女王i
    2020-12-19 21:25

    There is not a more "straightforward way" for a program to do this without modifying the registry. The ideal solution is to track the keypresses in a table (std::map, Dictionary, etc). The intent of this on MS's part is to prevent viruses/malware from taking control of the keyboard and preventing the user from using important keyboard combos such as WinKey-L and Ctrl-Alt-Delete.

    You can, however, remap the keyboard scan codes in the registry if keyboard hooking is not for you. This isn't ideal, since it's hard to reverse (especially if you make a mistake, or your program crashes, or the user uninstalls the application but the registry hack is not reverted). But it does work. Here are some references:

    http://www.howtogeek.com/howto/windows-vista/map-any-key-to-any-key-on-windows-xp-vista/

    http://www.howtogeek.com/howto/windows-vista/disable-caps-lock-key-in-windows-vista/

    http://www.usnetizen.com/fix_capslock.php

提交回复
热议问题