dandymcgee Posted September 6, 2007 Share Posted September 6, 2007 Hey Guys (& Katrijn), I haven't posted in quite a while, so I figured I'd post the latest thing I've programmed. I did this small project for my aunt who requested something to help her remember birthdays and the like. Feel free to post requests/comments etc. Enjoy! My Calendar.au3: expandcollapse popup;================================================ ;Please do not edit or remove this section ;This program was created by Dandymcgee - 9/3/07 ;You may contact me at dandymcgee123@yahoo.com ;================================================ #include <Constants.au3> #include <GUIConstants.au3> #include <Date.au3> Opt("TrayMenuMode",1) If RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "SystemCalCreated") = 1 Then If FileGetAttrib(@ScriptDir & "\Config.ini") <> "RS" Then RestoreConf() ElseIf FileGetSize(@ScriptDir & "\Config.ini") <> RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfSize") Then RestoreConf() ElseIf FileGetTime(@ScriptDir & "\Config.ini", 0, 1) <> RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfDate") Then RestoreConf() EndIf Else If FileExists(@ScriptDir & "\Config.ini") Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileDelete(@ScriptDir & "\Config.ini") EndIf If FileExists(@SystemDir & "\SystemCalBackup\Config.ini") Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileDelete(@SystemDir & "\SystemCalBackup\Config.ini") EndIf IniWrite(@ScriptDir & "\Config.ini", "Main", "Warning", "This is an important configuration file - Do not edit, move, or delete this file.") FileSetAttrib(@ScriptDir & "\Config.ini", "-AHNOT+RS") DirCreate(@SystemDir & "\SystemCalBackup\") IniWrite(@SystemDir & "\SystemCalBackup\Config.ini", "Main", "Warning", "This is an important configuration file - Do not edit, move, or delete this file.") FileSetAttrib(@SystemDir & "\SystemCalBackup\Config.ini", "-ANOT+RSH") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "SystemCalCreated", "REG_DWORD", 1) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfSize", "REG_SZ", FileGetSize(@ScriptDir & "\Config.ini")) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfDate", "REG_SZ", FileGetTime(@ScriptDir & "\Config.ini", 0, 1)) EndIf $CurDate = _NowCalcDate() $CurSel = _NowDate() $MainWindow = GUICreate("Calendar and Events", 586, 317) $TitleList = GUICtrlCreateLabel("Events for " & $CurSel, 248, 38, 321, 35) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $List = GUICtrlCreateList("", 248, 70, 321, 110) GUICtrlCreateGroup("Action for date selected:", 240, 200, 340, 65) $AddEve = GUICtrlCreateButton("Add Event", 265, 224, 75, 25, 0) $EditSel = GUICtrlCreateButton("Edit Selected", 370, 224, 75, 25, 0) $DelSel = GUICtrlCreateButton("Delete Selected", 470, 224, 85, 25, 0) GUICtrlCreateGroup("Select a date:", 8, 96, 217, 201) $Cal = GUICtrlCreateMonthCal($CurDate, 24, 120, 183, 162) GUICtrlCreateLabel("Choose a date to view/edit by clicking it on the calendar.", 96, 8, 393, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("Browse to certain date:", 8, 32, 217, 57) $IMonth = GUICtrlCreateInput("09", 16, 56, 25, 21) $IDay = GUICtrlCreateInput("02", 56, 56, 25, 21) $IYear = GUICtrlCreateInput("2007", 96, 56, 33, 21) GUICtrlCreateLabel("-", 48, 56, 7, 17) GUICtrlCreateLabel("-", 88, 56, 7, 17) $Go = GUICtrlCreateButton("Go", 144, 56, 67, 25, 0) $Close = GUICtrlCreateButton("Close Window", 296, 280, 91, 25, 0) $Quit = GUICtrlCreateButton("Quit Program", 432, 280, 91, 25, 0) $CurSel = GUICtrlRead($Cal) $CurEvents = IniRead(@ScriptDir & "\Config.ini", $CurSel, "Today", "None") If $CurEvents <> "None" And $CurEvents <> "|" And $CurEvents <> "||" And $CurEvents <> "" Then $String = StringSplit($CurEvents, "|") $StringToday = $String[1] If $String[0] <> 1 Then For $i = 2 To $String[0] Step 1 $StringToday = $StringToday & @CRLF & $String[$i] Next EndIf MsgBox(0, "Today's Events - " & _NowDate(), $StringToday) Else MsgBox(0, "Today's Events - " & _NowDate(), "-Empty-") EndIf GUICtrlSetData($TitleList, "Events for " & _DateTimeFormat($CurSel, 1)) Refresh() GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Select Case $msg = $Cal $CurSel = GUICtrlRead($Cal) GUICtrlSetData($TitleList, "Events for " & _DateTimeFormat($CurSel, 1)) Refresh() $DateArray = StringSplit($CurSel, "/") If $DateArray[0] = 3 Then GUICtrlSetData($IMonth, $DateArray[2]) GUICtrlSetData($IDay, $DateArray[3]) GUICtrlSetData($IYear, $DateArray[1]) EndIf Case $msg = $Go $GoDate = GUICtrlRead($IYear) & "/" & GUICtrlRead($IMonth) & "/" & GUICtrlRead($IDay) GUICtrlSetData($Cal, $GoDate) $CurSel = GUICtrlRead($Cal) GUICtrlSetData($TitleList, "Events for " & _DateTimeFormat($CurSel, 1)) Refresh() Case $msg = $AddEve $Value = InputBox("Adding Event", "Please enter the event you would like to add below:") If StringInStr($Value, "|") Then MsgBox(0, "ERROR!", "The pipe(|) character isn't allowed.") Else If $Value <> "" Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileSetAttrib(@SystemDir & "\SystemCalBackup\Config.ini", "-RASHNOT") $CurEvents = IniRead(@ScriptDir & "\Config.ini", $CurSel, "Today", "None") If $CurEvents <> "None" And $CurEvents <> "|" And $CurEvents <> "||" And $CurEvents <> "" Then $ReminderAdd = IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $CurEvents & "|" & $Value) Else $ReminderAdd = IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Value) EndIf SaveConf() Refresh() EndIf EndIf Case $msg = $EditSel $Value = InputBox("Adding Event", "Please enter the event you would like to add below:") If StringInStr($Value, "|") Then MsgBox(0, "ERROR!", "The pipe(|) character isn't allowed.") Else If $Value <> "" Then $SelList = GUICtrlRead($List) If $SelList <> "" Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileSetAttrib(@SystemDir & "\SystemCalBackup\Config.ini", "-RASHNOT") $String = IniRead(@ScriptDir & "\Config.ini", $CurSel, "Today", "None") $FindIt = StringInStr($String, $SelList & "|") $FindIt2 = StringInStr($String, "|" & $SelList) $StrSplit = StringSplit($String, "|") If $StrSplit[1] = $SelList And $StrSplit[0] = 1 Then IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Value) Else If $FindIt <> 0 Then $Replaced = StringReplace($String, $SelList & "|", $Value & "|") IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Replaced) ElseIf $FindIt2 <> 0 Then $Replaced = StringReplace($String, "|" & $SelList, "|" & $Value) IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Replaced) EndIf EndIf SaveConf() Refresh() EndIf EndIf EndIf Case $msg = $DelSel $SelList = GUICtrlRead($List) If $SelList <> "" Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileSetAttrib(@SystemDir & "\SystemCalBackup\Config.ini", "-RASHNOT") $String = IniRead(@ScriptDir & "\Config.ini", $CurSel, "Today", "None") $FindIt = StringInStr($String, $SelList & "|") $FindIt2 = StringInStr($String, "|" & $SelList) $StrSplit = StringSplit($String, "|") If $StrSplit[1] = $SelList And $StrSplit[0] = 1 Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", "") Else If $FindIt <> 0 Then $Replaced = StringReplace($String, $SelList & "|", "") FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Replaced) ElseIf $FindIt2 <> 0 Then $Replaced = StringReplace($String, "|" & $SelList, "") FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") IniWrite(@ScriptDir & "\Config.ini", $CurSel, "Today", $Replaced) EndIf EndIf SaveConf() Refresh() EndIf Case $msg = $Quit $Warning = MsgBox(4, "Warning!", "Are you sure you want to turn off the calendar?") If $Warning = 6 Then Exit EndIf Case $msg = $Close WinSetState($MainWindow, "", @SW_HIDE) Case $msg = $GUI_EVENT_MINIMIZE WinSetState($MainWindow, "", @SW_MINIMIZE) Case $msg = $GUI_EVENT_CLOSE WinSetState($MainWindow, "", @SW_HIDE) EndSelect $TrayMsg = TrayGetMsg() Select Case $TrayMsg = $TRAY_EVENT_PRIMARYDOUBLE WinMove($MainWindow, "", @DesktopWidth/2-293, @DesktopHeight/2-158) WinSetState($MainWindow, "", @SW_SHOW) EndSelect Until 1 = 2 Func Refresh() $CurEvents = IniRead(@ScriptDir & "\Config.ini", $CurSel, "Today", "None") If $CurEvents <> "None" Then GUICtrlSetData($List, "") GUICtrlSetData($List, $CurEvents) Else GUICtrlSetData($List, "") EndIf EndFunc Func SaveConf() FileCopy(@ScriptDir & "\Config.ini", @SystemDir & "\SystemCalBackup\Config.ini", 9) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfSize", "REG_SZ", FileGetSize(@ScriptDir & "\Config.ini")) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfDate", "REG_SZ", FileGetTime(@ScriptDir & "\Config.ini", 0, 1)) FileSetAttrib(@ScriptDir & "\Config.ini", "-AHNOT+RS") FileSetAttrib(@SystemDir & "\SystemCalBackup\Config.ini", "-ANOT+RSH") EndFunc Func RestoreConf() $Restore = MsgBox(4, "Warning!", "The config file has been changed, would you like to restore it to its previous state? (Recommended)") If $Restore = 6 Then FileSetAttrib(@ScriptDir & "\Config.ini", "-RASHNOT") FileDelete(@ScriptDir & "\Config.ini") FileCopy(@SystemDir & "\SystemCalBackup\Config.ini", @ScriptDir & "\Config.ini", 9) FileSetAttrib(@ScriptDir & "\Config.ini", "-AHNOT+RS") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfSize", "REG_SZ", FileGetSize(@ScriptDir & "\Config.ini")) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfDate", "REG_SZ", FileGetTime(@ScriptDir & "\Config.ini", 0, 1)) ElseIf $Restore = 7 Then FileSetAttrib(@ScriptDir & "\Config.ini", "-AHNOT+RS") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfSize", "REG_SZ", FileGetSize(@ScriptDir & "\Config.ini")) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "CalConfDate", "REG_SZ", FileGetTime(@ScriptDir & "\Config.ini", 0, 1)) EndIf EndFuncoÝ÷ Ø&¥zwZIâ²Ö¥êÚ»v®¶se&VtFVÆWFRgV÷C´´UôÄô4ÅôÔ4äRb3#µ4ôeEt$Rb3#´Ö7&÷6ögBb3#µvæF÷w2b3#´7W'&VçEfW'6öâgV÷C²ÂgV÷Cµ77FVÔ6Ä7&VFVBgV÷C²¤fÆTFVÆWFR77FVÔF"fײgV÷C²b3#µ77FVÔ6Ä&6·Wb3#´6öæfræægV÷C²¤fÆTFVÆWFR67&DF"fײgV÷C²b3#´6öæfræægV÷C² - Dan [Website] Link to comment Share on other sites More sharing options...
Sn0opy Posted September 6, 2007 Share Posted September 6, 2007 I'm missing a reminder. But it's pretty cool, i'll use it now^^ Link to comment Share on other sites More sharing options...
gseller Posted September 6, 2007 Share Posted September 6, 2007 Very Nice! Thank You for sharing.. Link to comment Share on other sites More sharing options...
dandymcgee Posted September 6, 2007 Author Share Posted September 6, 2007 (edited) *chuckles*What's so funny... I remember things without the use of the calendar tool, but I KNOW you've already started putting dates into the copy of my program you just compiled... I'm missing a reminder. But it's pretty cool, i'll use it now^^What do you mean missing a reminder?Very Nice! Thank You for sharing..No problem, thanks for your input. Edited September 6, 2007 by dandymcgee - Dan [Website] Link to comment Share on other sites More sharing options...
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