I'm sending keystrokes to an inactive Adobe Flash Projector window with PostMessage, that part works perfectly. I leave it running in the background and it interferes very little with my normal computer usage, which is the intent. The problem comes when I programmatically send the W
(or less frequently Q
) key while I happen to be holding Ctrl
intended for a different windows shortcut. This triggers Ctrl-Q
or Ctrl-W
, both of which immediately close the Adobe Flash Projector. Ctrl-F
and Ctrl-O
have some undesirable effects as well.
EDIT: I'm not interested in solutions that briefly release the Ctrl
key.
Is there anyway I can unhook shortcut keys from a third party window? It uses a standard OS menubar across the top of the window which is where the shortcuts are listed, so surely there's a way to reassign, unassign, or block it, right?
In the past I tried using these dlls to break the menu. It made it disappear but didn't break the shortcuts.
DllCall("SetMenu", uint, this.id, uint, 0) hMenu := DllCall("GetSystemMenu", "UInt",this.id, "UInt",1) DllCall("DestroyMenu", "Uint",hMenu)
Sorry for the strange syntax, this is from an early version of my program written in autohotkey.
The language I'm using now is C#, but I assume the solution uses a .dll, so that's not as important. Feel free to suggest or change my tags.
1 Answers
Answers 1
You can try to make inactive (
WS_DISABLED
- useGetWindowStyle
andSetWindowStyle
) the main window of destination application (the Window that contains menu).You can try to find which functions are used by application and rewrite them in local copy of application with
VirtualProtect
and injecting assembler (dangerous if you have no knowledge about virtualization of memory). Check the application useGetKeyState
orGetAsyncKeyState
(it will be visible after opening the application in text editor).You can try:
HMENU hMenu=GetMenu(applicationMainWindow); SetMenu(applicationMainWindow,0); // here send your input with SendMessageW instead of PostMessageW SetMenu(applicationMainWindow,hMenu);
Each program can use various methods to handle user keyboard input. In this case probably is used GetAsyncKeyState or GetKeyState (for Ctrl) if you didn't send it and Ctrl is detected.
If it won't help you, please add code with your PostMessage to your question.
BTW. Instead of destroying GetSystemMenu you can clear appropriate window style and after sending input restore it (if the problem is System Menu - probability near 1%).
0 comments:
Post a Comment