Jump to content

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


Recommended Posts

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.

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!
Link to comment
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!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...