Posts: 98
Threads: 46
Joined: Oct 2008
My macro runs on a software which has already F4 as accelartor key. Now my macro simply press F4 and enter key till the user keep F4 pressed. The macro runs fine in QM. But when compiled to exe it doesnot do anything and no error is generated. What could be the problem.
Macro just contain :
spe
'F4Y
Keyboard shortcut is also F4.
If I change the keyboard to any other key it works fine in exe too. But I want F4 only as keyboard trigger.
Posts: 12,140
Threads: 142
Joined: Dec 2002
Do you use RegisterHotKey in exe? If the target window used it first, your RegisterHotKey will fail (return 0). If you use it first, the target window will fail to register it. If the target window uses some other method to intercept the hotkey, then your RegisterHotKey will succed, but if your macro presses F4, it will be triggered itself. In either case, if you need F4 trigger, use low level keyboard hook instead of RegisterHotKey.
Posts: 98
Threads: 46
Joined: Oct 2008
Please provide a piece of code for low level keyboard hooks.
Posts: 12,140
Threads: 142
Joined: Dec 2002
Search for SetWindowsHookEx.
Posts: 98
Threads: 46
Joined: Oct 2008
How can I know that the target window is using what way to register hotkeys?
Posts: 12,140
Threads: 142
Joined: Dec 2002
You cannot know it. But if your hotkeys stop working when you open the window, you can guess that the program uses same method, or a lower level method, for example thread-specific hooks.