Jump to content

Check For Instance While Checkbox is Checked


Recommended Posts

Hi, so I've run into a second issue with my code. I'm making a reminder program to remind myself when my breaks are, and the way I've got it planned out is:

I put the times of my breaks in the boxes,

I check the checkbox to enable the reminders

And when the time comes for said break times, to pop up a box saying it is time for my break.

The issue I'm having is I can't seem to get it to update unless I un-check and then check my checkbox again. Would anyone have a solution for my issue? This is what I have so far: 

#AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 -w 6 -d

#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

Test()  

Func Test()
    Local $hGUI = GUICreate("Break Reminders")
    Local $idClose = GUICtrlCreateButton("Exit", 310, 370, 85, 25)
    Local $idApplyTimes = GuiCtrlCreateCheckbox("Apply Times", 5, 370, 85, 25)
    Local $NB1 = 0
    Local $NL = 0
    Local $NB3 = 0
    Local $NCO = 0
    Local $SecT = 1
    Local $Changed = 0
    $now = @HOUR & ":" & @MIN & ":" & @SEC
    $nowF = @HOUR & @MIN & @SEC
    $CurrentTime = GUICtrlCreateLabel($now, 175, 10, 120, 20)
    $CurrentTime2 = GUICtrlCreateLabel($nowF, 175, 25, 120, 20)
    $Break1 = GUICtrlCreateLabel("Break 1 Time", 40, 85, -1, -1)
    $Break1Time = GUICtrlCreateInput("00:00:00", 40, 100, -1, -1)
    $Lunch = GUICtrlCreateLabel("Lunch Time", 40, 150, -1, -1)
    $LunchTime = GUICtrlCreateInput("00:00:00", 40, 165, -1, -1)
    $Break3 = GUICtrlCreateLabel("Break 3 Time", 40, 210, -1, -1)
    $Break3Time = GUICtrlCreateInput("00:00:00", 40, 225, -1, -1)
    $ClockOut = GUICtrlCreateLabel("Clock Out Time", 40, 275, -1, -1)
    $ClockOutTime = GUICtrlCreateInput("00:00:00", 40, 290, -1, -1)
    ;$DebugVariableText = GUICTRLCreateLabel("DebugVariable", 160, 345, -1, -1)
    $ADebugVar = GUICtrlCreateLabel("DebugText", 160, 345, 120, 50)
    
    Global $Var1, $Var2
        ; Show GUI.
    
    GUISetState(@SW_SHOW, $hGUI)
        ; Loop begin
    While 1
            If $now <> @HOUR & ":" & @MIN & ":" & @SEC Then
                $now = @HOUR & ":" & @MIN & ":" & @SEC
                $nowF = @HOUR & @MIN & @SEC
                GUICtrlSetData($CurrentTime, $now)
                GUICtrlSetData($CurrentTIme2, $nowF)
            EndIf
        Switch GUIGetMsg()
            Case $idApplyTimes
                If GUICtrlRead($idApplyTimes) = $GUI_CHECKED Then
                ;   GUICtrlSetData($ADebugVar, "It working")
                    If $nowF < 220000 Then
                        GUICtrlSetData($ADebugVar, "Not After Break 1")
                    EndIf
                    
                    If  $nowF > 220000 Then
                    GUICtrlSetData($ADebugVar, "After Break 1") 
                    EndIf
                    
                    ;MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.", 0, $hGUI)

            EndIf   
                If GUICtrlRead($idApplyTimes) <> $GUI_CHECKED Then
                    GUICtrlSetData($ADebugVar, "Debug Text")
                EndIf
            Case $GUI_EVENT_CLOSE, $idClose 
                ExitLoop
            
        EndSwitch
            
    WEnd
    

    ;Unregister function to update time every second
    AdlibUnRegister(update_time)
    
EndFunc ; Test

Func update_time()
    GUICtrlSetData($CurrentTime, @HOUR & ":" & @MIN & ":" & @SEC)
EndFunc

At the moment I'm just trying to make it successfully update the var "ADebugVar" when the time comes without having to uncheck and check the checkbox again, so I just set the time manually in the code every time I test it

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