Sign in to follow this  
Followers 0
Mast3rpyr0

Daily Reminders

1 post in this topic

Little program that will popup reminders on the hour and day you set them for. The code is kinda messy and inefficent but it works.

Known issues:

-After creating a new reminder or deleting one, you cant do the same function again until you restart the program.

Im sure there is a very simple fix to this. Suggestions and fixes welcome!

#include <GUIConstants.au3>
#include <array.au3>
Opt("TrayAutoPause",0)
Opt("TrayMenuMode",1)


;Initialize Variables so that makegui() will work.
$reminderToDisplay = 0
$x = 1
$MainWindow = 0
$fileMenu = 0
$new = 0
$delete = 0
$hide = 0
$exit = 0
$INI = 0
$INI2 = 0
$restore = TrayCreateItem("Restore")
$exit2 = TrayCreateItem("Exit")

;Create New Reminder Window
$NewWindow = GUICreate("New Reminder", 300, 270)
$Reminder = GUICtrlCreateEdit("", 3, 3, 294, 150)
GUICtrlCreateLabel("Time: ", 3, 173)
$Time = GUICtrlCreateCombo("1", 50, 170, 75)
GUICtrlSetData($Time, "2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24", "12")
GUICtrlCreateLabel("Day: ", 150, 173)
$Day = GUICtrlCreateCombo("Every Day", 210, 170, 75)
GUICtrlSetData($Day, "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday", "Every Day")
$Cancel = GUICtrlCreateButton("Cancel", 40, 230, 100)
$Save = GUICtrlCreateButton("Save", 150, 230, 100)

;Create Delete Window
$DeleteWindow = GUICreate("Delete", 300, 75)
GUICtrlCreateLabel("Enter a reminder number to delete", 75, 3)
$delete2 = GUICtrlCreateInput("", 2, 20, 296)
$delete3 = GUICtrlCreateButton("Delete", 50, 45, 100)
$cancel2 = GUICtrlCreateButton("Cancel", 150, 45, 100)

MakeGUI()
GUISetState(@SW_SHOW, $MainWindow)


While 1
    $gMsg=GUIGetMsg(1)
    $tMsg=TrayGetMsg()
    Switch $gMsg[0]
    Case $Gui_Event_Close
        If $gMsg[1] = "0x006201D8" Then
            GUISetState(@SW_HIDE)
        Else
            GUISetState(@SW_HIDE, $gMsg[1])
        EndIf
    Case $GUI_EVENT_MINIMIZE
        GUISetState(@SW_HIDE, $MainWindow)
    Case $exit
        $close = MsgBox(4, "Exit?", "Are you sure you want to close Daily Reminder? Reminders will not be shown if you continue.")
        If $close = 6 Then
        Exit
        EndIf
    Case $hide
        GUISetState(@SW_HIDE, $MainWindow)
    Case $new
        If Ubound($INI) >= 10 Then
            MsgBox(0, "Error", "Daily Reminder can only store a max of 10 reminders.")
            Else
        GUISetState(@SW_SHOW, $NewWindow)
        EndIf
    Case $Save
        $Reminder = GUICtrlRead($Reminder)
        $Time = GUICtrlRead($Time)
        $Day = GUICtrlRead($Day)
        If $Day = "Sunday" Then
            $Day = 1
        ElseIf $Day = "Monday" Then
            $Day = 2
        ElseIf $Day = "Tuesday" Then
            $Day = 3
        ElseIf $Day = "Wednesday" Then
            $Day = 4
        ElseIf $Day = "Thursday" Then
            $Day = 5
        ElseIf $Day = "Friday" Then
            $Day = 6
        ElseIf $Day = "Saturday" Then
            $Day = 7
        EndIf
        If Ubound($INI) = 0 Then
        $s = Ubound($INI)+1
        Else
        $s = Ubound($INI)
        EndIf
        IniWriteSection(@Scriptdir & "\config.ini", $s, "Reminder=" & $Reminder & @LF & "Time=" & $Time & @LF & "Days=" & $Day)
        GUIDelete($MainWindow)
        MakeGUI()
        GUISetState(@SW_HIDE, $NewWindow)
        GUISetState(@SW_SHOW, $MainWindow)
    Case $delete
        GUISetState(@SW_SHOW, $DeleteWindow)
    Case $delete3
        $delete2 = GUICtrlRead($delete2)
        If $delete2 > 10 Then
            MsgBox(0, "Error", "You have entered an invalid Reminder number.")
        Else
        IniDelete(@ScriptDir & "\config.ini", $delete2)
        $f = $delete2
        For $i = $delete2 To 10 Step 1
            $n = IniRenameSection(@ScriptDir & "\config.ini", $i, $f, 1)
            If $n <> 0 Then
                $f += 1
            EndIf
        Next
        GUIDelete($MainWindow)
        MakeGUI()
        GUISetState(@SW_HIDE, $DeleteWindow)
        GUISetState(@SW_SHOW, $MainWindow)
    EndIf
    Case $Cancel
        GUISetState(@SW_HIDE, $NewWindow)
    Case $Cancel2
        GUISetState(@SW_HIDE, $DeleteWindow)
    EndSwitch
    Switch $tMsg
    Case $restore
        GUISetState(@SW_SHOW, $MainWindow)
    Case $exit2
        $close = MsgBox(4, "Exit?", "Are you sure you want to close Daily Reminder? Reminders will not be shown if you continue.")
        If $close = 6 Then
        Exit
        EndIf
    EndSwitch
    If @MIN = 00 And $x = 1 Then
    CheckRemind()
    EndIf
    If @MIN <> 00 And $x <> 1 Then
        $x = 1
    EndIf
WEnd


Func MakeGUI()
;Create Main Window
$MainWindow = GUICreate("Daily Reminders", 465, 400)

;Create Menus
;GUI Menus
$fileMenu = GUICtrlCreateMenu("File")
$new = GUICtrlCreateMenuItem("New", $fileMenu)
$delete = GUICtrlCreateMenuItem("Delete", $fileMenu)
$hide = GUICtrlCreateMenuItem("Hide", $fileMenu)
$exit = GUICtrlCreateMenuItem("Exit", $fileMenu)

;Setup GUI
GUICtrlCreateLabel("Reminder", 20, 20)
GUICtrlCreateLabel("Time", 242, 20)
GUICtrlCreateLabel("Day", 355, 20)

;Grab GUI data from INI and write to GUI
$INI = IniReadSectionNames(@ScriptDir & "\config.ini")
Local $v = 60
For $i = 1 To Ubound($INI)-1 Step 1
    $INI2 = IniReadSection(@ScriptDir & "\config.ini", $i)
    GUICtrlCreateLabel($i & ". " & $INI2[1][1], 20, $v)
    GUICtrlCreateLabel($INI2[2][1] & ":00", 242, $v)
    If $INI2[3][1] = 1 Then
        $INI2[3][1] = "Sunday"
    ElseIf $INI2[3][1] = 2 Then
        $INI2[3][1] = "Monday"
    ElseIf $INI2[3][1] = 3 Then
        $INI2[3][1] = "Tuesday"
    ElseIf $INI2[3][1] = 4 Then
        $INI2[3][1] = "Wednesday"
    ElseIf $INI2[3][1] = 5 Then
        $INI2[3][1] = "Thursday"
    ElseIf $INI2[3][1] = 6 Then
        $INI2[3][1] = "Friday"
    ElseIf $INI2[3][1] = 7 Then
        $INI2[3][1] = "Saturday"
    EndIf
    GUICtrlCreateLabel($INI2[3][1], 355, $v)
    $v += 30
Next
EndFunc

Func CheckRemind()
For $i = 1 To Ubound($INI)-1 Step 1
    $INI3 = IniReadSection(@ScriptDir & "\config.ini", $i)
    If @WDAY = $INI3[3][1] Or $INI3[3][1] = "Every Day" Then
    If @HOUR = $INI3[2][1] Then
        $reminderToDisplay = $INI3[1][1]
        Remind()
    EndIf
    EndIf
Next
EndFunc

Func Remind()
    MsgBox(32, "Reminder!", $reminderToDisplay)
    $x = 0
EndFunc

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