| View previous topic :: View next topic |
| Author |
Message |
cger
Joined: 18 Jul 2009 Posts: 9
|
Posted: Sat Jul 18, 2009 8:08 pm Post subject: Aborting a script |
|
|
Hello,
I've been using a different macro software for while. This software allowed the termination of the macro regardless of what stage it's in. I'm looking for a certain built-in feature in AutoHotKey, or a way to program in the key to abort the macro.
I've seen a couple of threads mentioning the ExitApp function. Although it does really terminate the macro, it will not happen until all lines are executed. Example:
| Code: |
Esc::ExitApp
^t::
SetKeyDelay, 100
Send Line one{ENTER}
Send Line two{ENTER}
Send Line three
return
|
I may be using this function inappropriately so if it is the way to go, a short example would be appreciated. The objective is preventing a mess if something unpredictable happens during the execution of a long macro.
Is this possible in any way?
Thanks,
Tom |
|
| Back to top |
|
 |
Dbof
Joined: 13 Jan 2009 Posts: 31
|
Posted: Sat Jul 18, 2009 8:14 pm Post subject: |
|
|
It depends on the macro. But in most cases, you can abort a macro by adding a hotkey:
| Code: | | Esc::ExitApp ;This exits the script whenever you press Escape |
|
|
| Back to top |
|
 |
cger
Joined: 18 Jul 2009 Posts: 9
|
Posted: Sun Jul 19, 2009 12:30 am Post subject: Aborting a Script |
|
|
Thanks Dbof,
This is the method I was referring to, but it didn't work even with the simplest example above. I tried adding the hotkey in various lines - before and after the main code, but regardless the hotkey executes only at the very end (after all 3 Sends are executed).
Tom |
|
| Back to top |
|
 |
evan1 Guest
|
Posted: Sun Jul 19, 2009 2:02 am Post subject: |
|
|
put some sleep in between, like:
| Code: | Esc::ExitApp
^t::
SetKeyDelay, 100
Send Line one{ENTER}
sleep 1
Send Line two{ENTER}
sleep 1
Send Line three
return |
|
|
| Back to top |
|
 |
cger
Joined: 18 Jul 2009 Posts: 9
|
Posted: Sun Jul 19, 2009 3:10 am Post subject: |
|
|
Not as easy as I'd hoped but it works. I'll add the sleep command where the potential for problems is the greatest.
Thanks!
 |
|
| Back to top |
|
 |
|