Bardolf Posted September 15, 2018 Posted September 15, 2018 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 expandcollapse popup#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
mikell Posted September 15, 2018 Posted September 15, 2018 Your date comparison is inconsistent. Look at this #include <Date.au3> Msgbox(0,"", _NowTime(4) & @crlf & @hour & ":" & @min)
Bardolf Posted September 15, 2018 Author Posted September 15, 2018 (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 September 16, 2018 by Bardolf
mikell Posted September 16, 2018 Posted September 16, 2018 The problem is here : On 15/09/2018 at 4:49 AM, Bardolf said: While GUICtrlRead($start) > _NowTime(4) And GUICtrlRead($end) < _NowTime(4) First it should be : start < current < end Second, it depends on what you write in the inputs : the minutes "mm" only or something like "hh:mm" or "hhmm" You can compare values only if they have the same format
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now