Jump to content

Recommended Posts

Posted

OK so I haven't used AutoIT in many years but I had need of a tool to pop up a reminder for me at set intervals.  I figured this would be easily achievable but for some reason, it is not going into the while loop.  The flow as I imagined it was I entered the start and finish times and selected odd or even timeslots.  As long as the current time was between that start and finish it would display the msgbox when the @MIN value equaled the set minutes.

Here is my code, any help would be greatly appreciated :)

 

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

Global $reminderGUI = GUICreate("Demo Reminder v1.2", 300, 130)
GUICtrlCreateLabel("Start Time", 59, 10)
Global $start = GUICtrlCreateInput("",57, 30)
Global $odd = GUICtrlCreateRadio("Odd",62, 60)
Local $startButton = GUICtrlCreateButton("START", 50, 90, 80)
GUICtrlCreateLabel("Finish Time", 199, 10)
Global $end = GUICtrlCreateInput("",197, 30)
Global $even = GUICtrlCreateRadio("Even", 202, 60)
Local $stopButton = GUICtrlCreateButton("STOP", 190, 90, 80)
Global $running = 0

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $startButton
            startReminder()
        Case $stopButton
            stopReminder()
    EndSwitch
WEnd

Func startReminder()

    $running = 1
    GUISetState(@SW_MINIMIZE)

    While GUICtrlRead($start) > _NowTime(4) And GUICtrlRead($end) < _NowTime(4)

        If $running <> 1 Then
            Return
        EndIf

        If GUICtrlRead($odd) = 1 Then
            If @MIN = 9 Or @MIN = 33 or @MIN = 49 Then
                MsgBox(0, "Demo reminder", "Check if you have a demo NOW!")
            EndIf
        ElseIf GUICtrlRead($even) = 1 Then
            If @MIN = 19 Or @MIN = 39 or @MIN = 59 Then
                MsgBox(0, "Demo reminder", "Check if you have a demo NOW!")
            EndIf
        EndIf

        Sleep(100)

    WEnd

EndFunc

Func stopReminder()
   $running = 0
EndFunc

 

Posted (edited)

@mikell OK, I'm sorry if this is stupid but I looked at that and I can't see any difference between the 2?  I tried building a variable using 

Global $time = @HOUR & ":" & @MIN

and then updating that every time the while loop runs but that made no difference.

Edited by Bardolf

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
×
×
  • Create New...