I have got registered global hot key, let's assume it's Ctrl + Shift + 1. So user presses this hot key and my action is launched. Unfortunately my action invokes another shortcut: Ctrl + V, to achieve it I have to first release keys related with hot key (I assume that a user will hold Ctrl + Shift and won't release them as soon as a hot key is activated).
Currently to release keys I use InputSimulator (under the hood it uses WinAPI method SendInput, InputSimulator source code) and it works.
The problem is when I try to restore Ctrl and Shift (user still holds them on keyboard and I don't want him to release and press them again to be able to invoke this hot key again).
If I simulate KeyDown, then keys stay down forever, even if I release them and press again, even if I restart application etc. I have to restart the computer or simulate KeyUp programmatically.
Does anyone know how can I restore keys again, to go back to the current physical keyboard state? I tried WinAPI methods: GetKeyboardState, SetKeyboardState, but it doesn't work.
Aucun commentaire:
Enregistrer un commentaire