Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
AntonS
- Newbie
- Posts: 1
- Joined: Sat Oct 15, 2005 11:02 am
Post
by AntonS » Sat Oct 15, 2005 11:06 am
Is it passible to do some actions by pressing some keyboard buttons.
For example I need to terminate macro by pressing Esc, is it possible??
WaitKeyDown>VK27
Label>Start
If>%WKD_result%=True,End
Random>8,r
ReadLn>c:\test.txt,r,line
Let>WW_TIMEOUT=5
CapsOff
MouseMove>203,685
Wait>1.99
LDblClick
Wait>2.29
wait>2
Send>line
Wait>1.28
Press Enter
Wait>1.28
Goto>Start
I'm using code like this but it doen't work((
Sorry for my english.
-
JRL
- Automation Wizard
- Posts: 3526
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Sun Oct 16, 2005 2:08 am
What you are trying to do will not work. The WaitKeyDown function stops your macro until the specified key is pressed then your macro continues. Therefore your third line where you have attempted to collect the value of a WaitKeyDown variable might as well say "goto>end" because it will always be true that you pressed the key. If you didn't press the key the macro would not continue.
There are ways to get around this by running multiple macros that are written to affect each other. Here is a short example:
DeleteFile>c:\~endlessloop~.scp
WriteLn>c:\~endlessloop~.scp,wresult,Let>k=0
WriteLn>c:\~endlessloop~.scp,wresult,Label>start
WriteLn>c:\~endlessloop~.scp,wresult,Let>k=k+1
WriteLn>c:\~endlessloop~.scp,wresult,Message>%k%
WriteLn>c:\~endlessloop~.scp,wresult,Wait>1
WriteLn>c:\~endlessloop~.scp,wresult,Goto>start
//Run>[path to Macro Scheduler]\msched.exe c:\~endlessloop~.scp
ExecuteFile>c:\~endlessloop~.scp
WaitKeyDown>VK27
Wait>1
Press Shift
Press ESC
Release Shift
This macro first writes to and creates a working macro file then executes that macro. It then waits for the ESC key to be pressed. When the ECS key is pressed this macro will continue and send Shift+ESC causing the executed macro to stop.
I've written this to use ExecuteFile to start the ~endlessloop~ macro. This works on my computer because the .scp extension is associated with Macro Scheduler. If a macro will not start with the ExecuteFile function on your computer, you can run msched.exe followed by the macro name as in the remarked line. Do not use the built in macro function since the processing of the original macro will stop until the called macro completes so you'll never get to the WaitKeyDown.
Sorry if this is confusing but its the only way I know how to do what it sounds like you want to do.
Dick