How can i make a loop until F5 is pressed on the keyboard?
for example:
Repeat>
Command 1
Command 2
Command 3
Command 4
Until> Waitkeydown>VK116
How can i convert what i just explained into Macro scheduler :S
Help with loop :/
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Use OnEvent.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
:/
well, i have this:
OnEvent>KEY_DOWN,VK116,0,(Dont Know What Gos Here)
Label>start
wait>1
Send Character/Text>test
Press Enter
Goto>start
what do i do from here to make the macro pause itself or quit itself when vk116 is pressed :/
OnEvent>KEY_DOWN,VK116,0,(Dont Know What Gos Here)
Label>start
wait>1
Send Character/Text>test
Press Enter
Goto>start
what do i do from here to make the macro pause itself or quit itself when vk116 is pressed :/
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Well, OnEvent calls a subroutine so you need a subroutine to handle the pause and you specify the subroutine name in OnEvent. This is how I would do it:
Pressing F5 will pause the script. When F5 is pressed DoPause is called which first sets paused to true. The main loop will then run the Repeat/Until loop - doing nothing while paused=true. If F5 is pressed again paused is set to false, so the repeat/until loop in the main loop now exits and the main loop can continue.
Note however that you can pause macros just by pressing the Pause key on your keyboard.
Code: Select all
OnEvent>KEY_DOWN,VK116,0,DoPause
Let>paused=false
Label>start
wait>1
SetFocus>Notepad*
Send Character/Text>test
Press Enter
//wait & do nothing if paused
Repeat>paused
//Do nothing
Wait>0.02
Until>paused=false
Goto>start
//Pause/Resume subroutine
SRT>DoPause
If>paused=false
Let>paused=true
Else
Let>paused=false
Endif
End>DoPause
Note however that you can pause macros just by pressing the Pause key on your keyboard.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
BTW - note that my example requires Notepad to be open. Notepad uses F5 for inserting date/time. So either use against another app, or change VK116 to VK115 to test against F4. It's just an example!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
hmm
Well i tried it this method and i have a little problem:
OnEvent>KEY_DOWN,VK115,0,pause
Label>start
wait>2
Send Character/Text>test
Press Enter
Goto>start
SRT>pause
WaitKeyDown>vk113
END>pause
-------
I wanted it to pause when i click F4 and resume when i click f2...
but this only works if i push F4 HARD on the keyboard for 1 second... i dont think i explained myself good enough
OnEvent>KEY_DOWN,VK115,0,pause
Label>start
wait>2
Send Character/Text>test
Press Enter
Goto>start
SRT>pause
WaitKeyDown>vk113
END>pause
-------
I wanted it to pause when i click F4 and resume when i click f2...
but this only works if i push F4 HARD on the keyboard for 1 second... i dont think i explained myself good enough