Jump to content

Toggle pause script


Go to solution Solved by somdcomputerguy,

Recommended Posts

Hi,

I've been using autoit for quite some years now and have mainly been lurking around the forums whenever I have had a problem. I've managed to get by through trial and error and I don't actually know very much about the program. I was wondering if I could get some help with my script.

My question is the following:

Is there a way to set a hotkey to pause my script but when I restart it, it begins from the beginning again rather than starting up where it paused?

For example.

Currently my script does.. ... pause at "c" >> unpause = starts at "d"

However I want it to do... ...   pause at "c" >> unpause = restarts at "a"

Here is what I am working with

;my script template

#requireadmin
    opt("SendKeyDownDelay", 200)
    $count = 0
Global $UnPaused
HotKeySet("`", "TogglePause")
HotKeySet("{ESC}", "Terminate")

;--------------------

While 1
    Sleep(10)
    ToolTip("Script is Paused",0,0)
WEnd

;--------------------

Func TogglePause()
    $UnPaused = NOT $UnPaused
    While $UnPaused

;---script goes here--
Send("a")
Send("b")
Send("c")
Send("d")

;--------------------

  WEnd
EndFunc

;--------------------

Func Terminate()
   Exit 0
EndFunc

Any help is greatly appreciated!

 

- Alex

Link to comment
Share on other sites

Ah, thank you for that. It works great.

With the method shown above I seem to require another hotkeyset (it pauses + resets script, but pressing it again does not start it up again)

Out of curiousity, is there a way to merge my toggle and this new "restart" hotkey? If not, this will work fine.

Edited by thechinesekid
Link to comment
Share on other sites

After the While..WEnd loop, where there is the line ToolTip(""), is where I would put the 'restart code' (after the blank tooltip line, not replacing it). So there would be only one hotkey, whichever one you have set to call the pause function.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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