AutoHotkey Community

It is currently May 26th, 2012, 8:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Aborting a script
PostPosted: July 18th, 2009, 9:08 pm 
Offline

Joined: July 18th, 2009, 8:46 pm
Posts: 9
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 18th, 2009, 9:14 pm 
Offline

Joined: January 13th, 2009, 10:02 pm
Posts: 31
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Aborting a Script
PostPosted: July 19th, 2009, 1:30 am 
Offline

Joined: July 18th, 2009, 8:46 pm
Posts: 9
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2009, 3:02 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 19th, 2009, 4:10 am 
Offline

Joined: July 18th, 2009, 8:46 pm
Posts: 9
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!

:D


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, over21, SifJar, SKAN, StepO and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group