Jump to content
Sign in to follow this  
gswitzer

GUI time out queestion

Recommended Posts

gswitzer

Hi there all,

I'm trying to build a GUI with two click controls, and I'd like it to timeout if a ctrl isn't pressed in 5 minutes. Any ideas or samples of code you could point me to? Thank you!

G.

Share this post


Link to post
Share on other sites
Kogmedia

Hi there all,

I'm trying to build a GUI with two click controls, and I'd like it to timeout if a ctrl isn't pressed in 5 minutes. Any ideas or samples of code you could point me to? Thank you!

G.

#include <Date.au3>
Global $Secs, $Mins, $Hour, $Time
$timer = TimerInit()
AdlibEnable("Timer", 50)

Func Timer()
  _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
  Local $sTime = $Time  ; save current time to be able to test and avoid flicker..
  $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
  If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time)
EndFunc  ;==>Timer

Here is a timer script

If $Mins = 5 then disable control

~Kog~

Edited by Kogmedia

[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search

Share this post


Link to post
Share on other sites
gswitzer

Thanks for the info guys. I'm a little unclear on where to put it into the code though:

$AutoUpdater = GUICreate("Updater 3.0", 433, 170, 452, 422,)

GUISetIcon("path to ico")

GUISetBkColor(0xFFFF00)

$Continue = GUICtrlCreateButton("&Continue", 64, 120, 75, 25)

$Cancel1 = GUICtrlCreateButton("&Cancel", 271, 121, 75, 25)

$Label1 = GUICtrlCreateLabel("Update info", 48, 32, 341, 17)

GUISetState(@SW_SHOW)

$nMsg = 0

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Cancel1

Exit

Case $nMsg = $Continue

ExitLoop

EndSelect

WEnd

I tried using the timediff starttimer functions, and I could get it to run the timer for a period of time, but I couldn't get it into the dialog above. Thanks again for the advice.

Share this post


Link to post
Share on other sites
gswitzer

I want it to close the dialog completely and continue on with the script.

Share this post


Link to post
Share on other sites
Kogmedia

#include <Date.au3>
#include <GUIConstants.au3>
Global $Secs, $Mins, $Hour, $Time
$timer = TimerInit()
AdlibEnable("Timer", 50)

$AutoUpdater = GUICreate("Updater 3.0", 433, 170, 452, 422)
GUISetIcon("path to ico")
GUISetBkColor(0xFFFF00)
$Continue = GUICtrlCreateButton("&Continue", 64, 120, 75, 25)
$Cancel1 = GUICtrlCreateButton("&Cancel", 271, 121, 75, 25)
$Label1 = GUICtrlCreateLabel("Update info", 48, 32, 341, 17)

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
If $Mins = 5 Then ExitLoop
Select
    Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Cancel1
        Exit
    Case $nMsg = $Continue
ExitLoop



EndSelect

WEnd

Func Timer()
  _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
  Local $sTime = $Time  ; save current time to be able to test and avoid flicker..
  $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
  If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time)
EndFunc  ;==>Timer


[font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search

Share this post


Link to post
Share on other sites
gswitzer

That worked great! Thanks to you, sir, Kogmedia!

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  

×