Jump to content

Tray Pause from button


 Share

Recommended Posts

Hey, so I've been searching around for a while now and I've seen very interesting methods for pausing a script and picking back up where it left off. But I have yet to see what I would imagine to be the most simple method. Is there no way to invoke/call what ever command it is that is executed when we pause a script from the tray menu. Either I'm just blind ^_^ or there's no listed way (Help File) ;) to route the execution of the "Tray Script Pause" to another source . If someone has already discussed this please just route me to the post. I have no problem reading up on it.

just curious. Thanks!

**The only limit is what you believe they tell you it is**

Link to comment
Share on other sites

Why would simply setting a hotkey not work?

HotKeySet("{F2}","PauseScript")
HotKeySet("{F3}","UnpauseScript")
;; Code here

Func PauseScript()
     $Toggle = True
     While $toggle = True
          Sleep(200)
     WEnd
EndFunc

Func UnpauseScript()
     $Toggle = False
EndFunc

Oh I'm not saying that wouldn't work. That's one of the methods I came across. The thing is though is I don't want to use a hotkey. My GUI has a button for pausing that I would like to use and that method's no quite working out so easily. But more so than anything i just wanted to know if it's even possible to route that command since it works so well and it's already there.

Thanks for the reply BinaryBrother!

**The only limit is what you believe they tell you it is**

Link to comment
Share on other sites

Oh I'm not saying that wouldn't work. That's one of the methods I came across. The thing is though is I don't want to use a hotkey. My GUI has a button for pausing that I would like to use and that method's no quite working out so easily. But more so than anything i just wanted to know if it's even possible to route that command since it works so well and it's already there.

Thanks for the reply BinaryBrother!

I would think that the pause function used in the traymenu would be of little use to you because if you could call the function you wouldn't be able to start your script again without using the tray menu.

You should be able to pause using a button though unless you have a function which is called by an event and which takes a long time. In that case I would replace the function with one that just sets a variable and have the idle loop check that variable and call the function when needed, then another event, like the button press, can take immediate effect and pause the program

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I would think that the pause function used in the traymenu would be of little use to you because if you could call the function you wouldn't be able to start your script again without using the tray menu.

You should be able to pause using a button though unless you have a function which is called by an event and which takes a long time. In that case I would replace the function with one that just sets a variable and have the idle loop check that variable and call the function when needed, then another event, like the button press, can take immediate effect and pause the program

I figured that if we had to ability call the command via a button that we would be able to unpause it the same way, but now that you mention it i see you point. The GUI would probably be completely locked. Well that answers that question ^_^ .

You gave me an idea with you suggestion. There is a point in my script were it sleeps for the amount of time specified by the end user. Instead of a sleep I used loop (DO UNTIL) to check the GUIMsg until the specified time is up. The one problem with that was the pause. As soon as I unpaused the script it would count the paused time as time used. So I set up an extra Timer to monitor the pause time and subtract that time from the original user specified time.

Loop

[/code]
$StartTimer = TimerInit()
        Do 
            _Check_GUI()
        Until   (TimerDiff($StartTimer) - $PauseDiff) >= $sleep
Check gui and start 2nd timer
Func _Pause_Interpret() If $Paused = False Then $Paused = True $PauseTimer = TimerInit() While $Paused = True $nMsg = GUIGetMsg() Switch $nMsg Case $Play_Button _Pause_Interpret() Case $Pause_Button _Pause_Interpret() Case $Next_Button EndSwitch WEnd Else $Paused = False $PauseDiff = TimerDiff($PauseTimer) EndIfEndFunc
Thanks for the help both of you   .

**The only limit is what you believe they tell you it is**

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