Jump to content

Recommended Posts

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
Posted

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.

  • Developers
Posted

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.
  :)

Posted

That's pretty easy actually...

Just copy this code :

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

Func CLOSE()
Exit
EndFunc

Good luck with your script !

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
  • Recently Browsing   0 members

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