Sign in to follow this  
Followers 0
thegreatconductor

How To Have The Macro Stop When A Key Is Pressed?

8 posts in this topic

#1 ·  Posted (edited)

I need to setup my macro to run infinitely in a loop but then have a keypress abort the macro such as F10 so when the F10 key is hit the macro stops. Can anyone please help me with this?

Thanks in advance for your help

Edited by thegreatconductor

Share this post


Link to post
Share on other sites



This is a popular version.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{F10}", "Terminate"); example F10 to exit
HotKeySet("{ESC}", "Terminate")

; put in your script here



Func TogglePause()
   $Paused = NOT $Paused
   While $Paused
       sleep(100)
       ToolTip($paused&'Script is "Paused"',0,0)
   WEnd
   ToolTip($paused)
EndFunc

Func Terminate()
   Exit 0
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

Adapted version from the helpfile:

HotKeySet("{F10}", "Terminate")

;;;; Body of program would go here;;;;
While 1
  ; do what you need to do in the loop
    Sleep(100)
WEnd
;;;;;;;;

Func Terminate()
    Exit 0
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Based on the example in the help file for HotKeySet:

HotKeySet("{F10}", "Terminate")

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;


Func Terminate()
    Exit 0
EndFunc

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

That's pretty easy actually...

Just copy this code :

HotKeySet("{F10}", "CLOSE")

Func CLOSE()
Exit
EndFunc

Good luck with your script !

Share this post


Link to post
Share on other sites
:whistle: Seems like everybody was writing something at the same time her B)

Share this post


Link to post
Share on other sites

That is too funny, it was posted almost a half hour ago, and we all deside to post on it at the same time. :whistle:


AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

That is too funny, it was posted almost a half hour ago, and we all deside to post on it at the same time. B)

Actually, I'd say it's impressive that every post was informative instead of simply "RTFM." What a great community :whistle:

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0