Newb Posted December 5, 2010 Share Posted December 5, 2010 Hi, I'm doing a script that automatizes some file saving processes with a rendering program. Since there are predefined times in the rendering elaboration the click times are fine like they are in my script. But sometimes they take a little longer so i would like to pause with an hotkey the script. I know it can be made with Sleep() command. But I would like to know how I can pause the script without starting the re-execution all over. When I pause the script it's fine, but when I unpause it, it restarts all over, I need to know how I can do some sort of checkpoint so when it unpauses it starts back from where it was interrupted. This is the sourcecode: expandcollapse popupHotKeySet("{F2}","Chiudere") HotKeySet("{F3}","StartStop") $dd=False While 1 Sleep (10) WEnd Func StartStop() $dd= Not $dd If $dd=True Then On() Else Off() EndIf EndFunc Func On() While 1 Sleep(1000) MouseClick("right",335,374) Sleep(120000) MouseClick("right",401,545) Sleep(120000) MouseClick("right",230,552) Sleep(120000) Mouseclick("right",236,442) Sleep(120000) Wend EndFunc Func Off() While 1 Sleep (10) WEnd EndFunc Func Chiudere() Exit EndFunc Thanks for your time. I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 5, 2010 Share Posted December 5, 2010 See the example here, HotKeySet. When a script is paused this way, it'll pick up where it was before the pause. Here's another example, just use the 'pause' hotkey after starting the script, and before it ends:Global $Paused HotKeySet("^p", "TogglePause") ; ^p = CTRL + P While 1 For $i = 1 to 10 ConsoleWrite($i & " ") Sleep(500) Next ConsoleWrite("- All Done!" & @LF) Exit WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Newb Posted December 5, 2010 Author Share Posted December 5, 2010 See the example here, HotKeySet. When a script is paused this way, it'll pick up where it was before the pause. Here's another example, just use the 'pause' hotkey after starting the script, and before it ends: Global $Paused HotKeySet("^p", "TogglePause") ; ^p = CTRL + P While 1 For $i = 1 to 10 ConsoleWrite($i & " ") Sleep(500) Next ConsoleWrite("- All Done!" & @LF) Exit WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Ok, I saw a similar example in some guide, I think I can find a workaround for it. Thanks I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 5, 2010 Share Posted December 5, 2010 Ya that code is mostly a copy/paste from the Helpfile for HotKeySet, I just added a simple counter so one can see the 'pause effect'. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now