Jump to content

Series of countdown/looping timers


tater
 Share

Recommended Posts

Hi everyone. I'm trying to make a Quake Arena timer that will keep track of 3 basic variables. I've done this easily but the lack of a GUI doesn't make it as enjoyable or appealing to me anymore. Unfortunately I have absolutely no idea what to do at this point.

#include <GUIConstantsEx.au3>

Timer()

Func Timer()
    Local  $quad, $yellowarmor, $redarmor, $msg
    GUICreate("Timer") 


    $quad = GUICtrlCreateCheckbox("Quad Damage", 12, 80, 120,20)
    $yellowarmor = GUICtrlCreateCheckbox("Yellow Armor", 12, 100, 120,20)
    $redarmor = GUICtrlCreateCheckbox("Red Armor", 12, 120, 120,20)



    GUISetState()    


    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        EndSelect
    WEnd
EndFunc

Now I don't know what to do here because without a GUI I would just set hotkeys and make them loop. So my questions are the following:

If a checkbox is selected, can you assign a hotkey to it so that it can loop? If so, please give me a brief explanation how/where this would go in the program.

Would I need to create a sort of 'Start' button so that timers don't start instantly (assuming you cannot assign a hotkey)?

Any additional information anyone provides will be greatly appreciated. I'm not that great of a programmer (especially when it comes to dialogs) but I'm trying to learn! Sorry for the novice questions.

Thank you for any help!

Link to comment
Share on other sites

Thank you for the reply and help Rasim!

#include <GUIConstantsEx.au3>

Timer()

Func Timer()
    Local  $quad, $yellowarmor, $redarmor, $msg
    GUICreate("Timer")


    $quad = GUICtrlCreateCheckbox("Quad Damage", 12, 80, 120,20)
    $yellowarmor = GUICtrlCreateCheckbox("Yellow Armor", 12, 100, 120,20)
    $redarmor = GUICtrlCreateCheckbox("Red Armor", 12, 120, 120,20)



    GUISetState()   


    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        Case $msg = $quad and BitAND(GUICtrlRead($quad), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:','Quad will be timed at 55 seconds.')
            HotKeySet("{UP}", "Quad")
        Case $msg = $yellowarmor and BitAND(GUICtrlRead($yellowarmor), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:','Yellow will be timed at 30 seconds.')
        Case $msg = $redarmor and BitAND(GUICtrlRead($redarmor), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:','Red will be timed at 25 seconds.')
                                    
        EndSelect

    WEnd
EndFunc   

Func Quad()
        MsgBox(64, 'Test', 'Test')
EndFunc

Now the only problem I'm having is the hotkey still going on even when the field is not checked. How would you disable it if it's not checked?

Many thanks!

Link to comment
Share on other sites

@tater

Try this:

#include <GUIConstantsEx.au3>

Timer()

Func Timer()
    Local $quad, $yellowarmor, $redarmor, $msg
    GUICreate("Timer")

    $quad = GUICtrlCreateCheckbox("Quad Damage", 12, 80, 120, 20)
    $yellowarmor = GUICtrlCreateCheckbox("Yellow Armor", 12, 100, 120, 20)
    $redarmor = GUICtrlCreateCheckbox("Red Armor", 12, 120, 120, 20)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $quad
                If BitAND(GUICtrlRead($quad), $GUI_CHECKED) Then
                    MsgBox(64, 'Info:', 'Quad will be timed at 55 seconds.')
                    HotKeySet("{UP}", "Quad")
                Else
                    MsgBox(64, 'Info:', 'Quad timer disabled.')
                    HotKeySet("{UP}")
                EndIf
            Case $msg = $yellowarmor And BitAND(GUICtrlRead($yellowarmor), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'Yellow will be timed at 30 seconds.')
            Case $msg = $redarmor And BitAND(GUICtrlRead($redarmor), $GUI_CHECKED) = $GUI_CHECKED
                MsgBox(64, 'Info:', 'Red will be timed at 25 seconds.')
        EndSelect

    WEnd
EndFunc   ;==>Timer

Func Quad()
    MsgBox(64, 'Test', 'Test')
EndFunc   ;==>Quad

:)

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