WaitKeyDown - Combination of Keys in compiled marco

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

WaitKeyDown - Combination of Keys in compiled marco

Post by kpassaur » Sat Sep 24, 2005 4:19 pm

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

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Sat Sep 24, 2005 6:53 pm

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

Danish_Ken
Junior Coder
Posts: 22
Joined: Mon Sep 12, 2005 1:34 am
Location: Melbourne - Australia

Post by Danish_Ken » Thu Sep 29, 2005 6:05 am

Hmm

Isn't SHIFT+F12 the same as F24
As in: all SHIFT+F1-12 is the same as F13-24

VK_F24 (135)
Macro Scheduler since Version 5.0 - 21/10/1998

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Function keys activating other programs

Post by kpassaur » Thu Sep 29, 2005 11:05 am

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.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts