Is there a way to wait for key press Combo (or Hot Keys) with WaitKeyDown? Such as Shift + F1 or some combo like that? It would be used in a compiled marco.
I tried WaitKeyDown>VK112+VK27 for ESC + F1 and no go
I understand it may not be possible, as there are no examples of waiting for two keys being pressed in the help files. But perhaps someone figured out something
WaitKeyDown - Combination of Keys in compiled marco
Moderators: JRL, Dorian (MJT support)
Here you go, this script uses F12+Shift
let>VK_F12=123
let>VK_SHIFT=16
///1st part is to make sure keys are not active and set to 0
///Part 1
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
if>KEY_PRESSED1=1
press f12
endif
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>KEY_PRESSED2=1
press shift
release shift
endif
///Part 2 (main Part)
label>WaitKeyPressedLoop
wait>.0005
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>{(%KEY_PRESSED1%=1)and(%KEY_PRESSED2%=1)},NextStep
goto>WaitKeyPressedLoop
///Reset key state back to 0 (zero)
///Part 3
label>NextStep
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
if>KEY_PRESSED1=1
press f12
endif
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>KEY_PRESSED2=1
press shift
release shift
endif
...
mdl>Worked!%crlf%Click OK
Do something
...
goto>WaitKeyPressedLoop
let>VK_F12=123
let>VK_SHIFT=16
///1st part is to make sure keys are not active and set to 0
///Part 1
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
if>KEY_PRESSED1=1
press f12
endif
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>KEY_PRESSED2=1
press shift
release shift
endif
///Part 2 (main Part)
label>WaitKeyPressedLoop
wait>.0005
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>{(%KEY_PRESSED1%=1)and(%KEY_PRESSED2%=1)},NextStep
goto>WaitKeyPressedLoop
///Reset key state back to 0 (zero)
///Part 3
label>NextStep
LibFunc>User32,GetKeyState,KEY_PRESSED1,VK_F12
if>KEY_PRESSED1=1
press f12
endif
LibFunc>User32,GetKeyState,KEY_PRESSED2,VK_SHIFT
if>KEY_PRESSED2=1
press shift
release shift
endif
...
mdl>Worked!%crlf%Click OK
Do something
...
goto>WaitKeyPressedLoop
-
- Junior Coder
- Posts: 22
- Joined: Mon Sep 12, 2005 1:34 am
- Location: Melbourne - Australia
Function keys activating other programs
Thank you for the script.
I tried the script above and it worked great. But, yes there is a but. I modified it so that F11 would run one routine and F12 another. However, with testing I found that it was dependant upon what other applications were running on the PC. For instance if Internet Explorer was running in the backgound the F11 Key would change it's window.
I am not good enough to understand the script above, but it looked to me from the remarks that it was disabling other appliations from accessing the keys so that Macro Scheduler could use them.
It appears to me and I could be wrong - that there is no way to disable the key requests used by other applications. The goal was to have the function key activate a script that collects data off of the screen. I could use the set focus to go to the right applicaion (I have this in the script) but when I press the function keys it seems other applications always and I mean always use whatever combination that I try.
Has anyone run into this before?
My latest try is not based on using the above script but on using two keys with a timer. If you press F11 twice within two seconds it activates the program. If not it resets the timer. There is difficulties with this as well. The closest I have come is to use the up and down arrow keys. I have not yet tried the up and down arrow keys with the above script that it next. However, if someone know of some combo that is universal it would sure help out.
I tried the script above and it worked great. But, yes there is a but. I modified it so that F11 would run one routine and F12 another. However, with testing I found that it was dependant upon what other applications were running on the PC. For instance if Internet Explorer was running in the backgound the F11 Key would change it's window.
I am not good enough to understand the script above, but it looked to me from the remarks that it was disabling other appliations from accessing the keys so that Macro Scheduler could use them.
It appears to me and I could be wrong - that there is no way to disable the key requests used by other applications. The goal was to have the function key activate a script that collects data off of the screen. I could use the set focus to go to the right applicaion (I have this in the script) but when I press the function keys it seems other applications always and I mean always use whatever combination that I try.
Has anyone run into this before?
My latest try is not based on using the above script but on using two keys with a timer. If you press F11 twice within two seconds it activates the program. If not it resets the timer. There is difficulties with this as well. The closest I have come is to use the up and down arrow keys. I have not yet tried the up and down arrow keys with the above script that it next. However, if someone know of some combo that is universal it would sure help out.