Sign in to follow this  
Followers 0
thebman

Selection box with count down timer

3 posts in this topic

I have most of this written, but I do not have the source in front of me at the moment. I will use pseudo code to explain what I'm trying to do.

Create Window with 2 radio buttons and a 20 second count down timer that starts counting down as soon as the window is opened.

radio_1 = default selection (already clicked)

radio_2

If user selects radio_1; then delete window and continue down radio_1 path

If user selects radio_2; then delete window and continue down radio_2 path

Now here is where I need help, what I want the 20 second timer for is that if the user does not select a radio button by the time the timer hits 0 then the window should close and the default selection should be used as the path to continue down (radio_1 in this case)

I need help with the timer part and also how to make the code select the default button as the selection to continue down.

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hmm.. sounds interesting, lemme see if I can whip something up quickly.

*Edit: Done, how's this look for a starting point?

#include <GUIConstantsEx.au3>
#include <Timers.au3>

Global $iCountdown = 20

$hGUI = GUICreate('', 200, 200)
$lb_Stat = GUICtrlCreateLabel('Countdown: ' & $iCountdown, 5, 5, 80, 15)
$ra_Opt1 = GUICtrlCreateRadio('Option 1', 5, 25, 60, 20)
    GUICtrlSetState(-1, $GUI_CHECKED)
$ra_Opt2 = GUICtrlCreateRadio('Option 2', 5, 45, 60, 20)

GUISetState()

_Timer_SetTimer($hGUI, 1000, '_Countdown')

While 1
    $gm = GUIGetMsg()
    Switch $gm
        Case $ra_Opt1
            GUIDelete()
            MsgBox(0, 'Option 1', 'Option 1 has been chosen')
            ExitLoop
        Case $ra_Opt2
            GUIDelete()
            MsgBox(0, 'Option 2', 'Option 2 has been chosen')
            ExitLoop
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func _Countdown($hWnd, $iMsg, $iIDTimer, $dwTime)
    $iCountdown -= 1
    If $iCountdown > 0 Then
        GUICtrlSetData($lb_Stat, 'Countdown: ' & $iCountdown)
    ElseIf $iCountdown = 0 Then
        _Timer_KillTimer($hWnd, $iIDTimer)
        ControlClick($hGUI, '', $ra_Opt1)
    EndIf
EndFunc
Edited by RobSaunders

Share this post


Link to post
Share on other sites

I Like It! :P

This is much appreciated, this will definitly help me finish my script.

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