Sign in to follow this  
Followers 0
thechinesekid

Toggle pause script

6 posts in this topic

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

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Hmm, I gave it a shot but it got really messy. I get the feeling quite a bit of work will be needed to merge the two functions so I'll stick to what you've given me. I was just wondering for convenience.

Thanks

Share this post


Link to post
Share on other sites

Basically I was just telling you where I would start. I don't have a woking solution to supply, and I'm sure that there would be at least a few obstacles to overcome. Good luck though! :bye:


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

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