Jump to content

Rex

Active Members
  • Posts

    570
  • Joined

  • Last visited

Everything posted by Rex

  1. Internal update worked fine for me. What version are you on? /Rex
  2. @InunoTaishou Do you use the dark theme ? For me the text in console is white, using Dark Theme Cheers /Rex
  3. @nimmer This is sadly a known issue, some antivirus vendors flags ALL programs created with Autoit as virus, due to what I guess is laziness Copy pasted the hello world tutorial from the help file, compiled it and added it to virus total which gave this result https://www.virustotal.com/gui/file/cdc9ef08b8125c4cf7953a0ea6dd7adca8c8552652c716132bd66b7b7fe0cda4/details Cheers /Rex
  4. Or use the extended GuiCtrlRead #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 195, 125) $Button1 = GUICtrlCreateButton("ok", 86, 64, 75, 34) Dim $Checkbox[3] $Checkbox[0] = GUICtrlCreateCheckbox(".JPG", 14, 32, 49, 17) $Checkbox[1] = GUICtrlCreateCheckbox(".PNG", 68, 32, 49, 17) $Checkbox[2] = GUICtrlCreateCheckbox(".GIF", 127, 32, 49, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To UBound($Checkbox) - 1 If GUICtrlRead($Checkbox[$i]) = $GUI_CHECKED Then ConsoleWrite(GuiCtrlRead($Checkbox[$i], $GUI_READ_EXTENDED) & @CRLF) Next EndSwitch WEnd
  5. I can confirm the smallicons.dll bug, I think that it's course when starting a .isn file the scriptdir changes from the studio install path to the isn file path. I did get the same err when beta testing 09, but both ISI and I thought that it was be course I ran the studio from the source using a wrapper, and therefor the workdir got thrown off. To use the DBUG from the studio, go to Tools -> Debugging -> Advanced Debugging with DBUG, and click Activate Now when you start your project, the DBUG will run Cheers /Rex
  6. I think that I would do something like this #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 349, 254, 886, 439) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $idLbl_1 = GUICtrlCreateLabel("Browse for App:", 8, 8, 79, 17) Global $idInp_1 = GUICtrlCreateInput("", 8, 24, 265, 21) Global $idBtn_1 = GUICtrlCreateButton("&Browse", 280, 24, 59, 21) GUICtrlSetOnEvent(-1, 'Browse') Global $idBtn_2 = GUICtrlCreateButton("&Add to list", 8, 56, 75, 21) GUICtrlSetOnEvent(-1, 'Add') Global $idLbl_2 = GUICtrlCreateLabel("Apps to install:", 8, 88, 72, 17) Global $idList_1 = GUICtrlCreateList("", 8, 104, 329, 110) Global $idBtn_3 = GUICtrlCreateButton("&Start", 8, 224, 75, 21) GUICtrlSetOnEvent(-1, 'Install') Global $idBtn_4 = GUICtrlCreateButton("&Remove Selected", 240, 224, 100, 21) GUICtrlSetOnEvent(-1, 'Remove') GUISetState(@SW_SHOW) ; Set focus to the browse button GUICtrlSetState($idBtn_1, $GUI_FOCUS) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc ;==>Form1Close Func Browse() Local $sPath = FileOpenDialog("Select an application for install", "\\servername\foldername\foldername\testfoldername\", "All file (*.*)") GUICtrlSetData($idInp_1, $sPath) ; Set focus to the add button to allow the user to just hit enter to add the item GUICtrlSetState($idBtn_2, $GUI_FOCUS) EndFunc ;==>Browse Func Add() ; Add selected item to ListBox GUICtrlSetData($idList_1, GUICtrlRead($idInp_1)) ; Clear the Input GUICtrlSetData($idInp_1, '') ; Retur focus to the browse button GUICtrlSetState($idBtn_1, $GUI_FOCUS) EndFunc ;==>Add Func Install() ; Reading items in the ListBox ; Method 1 just run the damn things For $i = 0 To _GUICtrlListBox_GetCount($idList_1) - 1 RunWait(_GUICtrlListBox_GetText($idList_1, $i)) ; Remove the executed item from the list, this gives the user a hint of where in the list we are _GUICtrlListBox_DeleteString($idList_1, $i) Next ; Method 2 create an array with the items from ListBox and the run the array ; We could create the read to array our self, but we'r lazy so we just use guinness from here ; https://www.autoitscript.com/forum/topic/145997-_guictrllistbox_createarray-create-an-array-from-a-listbox/ Local $aItems = _GUICtrlListBox_CreateArray($idList_1) For $i = 1 To $aItems[0] RunWait($aItems[$i]) ; Remove the executed item from the list, this gives the user a hint of where in the list we are _GUICtrlListBox_DeleteString($idList_1, $i - 1) ; We started at 1 not 0 so we have to substract 1 to get the correct index Next EndFunc ;==>Install Func Remove() ; Remove selected item(s) from ListBox Local $aSelected = _GUICtrlListBox_GetSelItems($idList_1) ; Check that at least one item is selected, GetSelItems returns = 0 even it nothing is selected or exists in the ListBox If GUICtrlRead($idList_1) = "" Then Return For $i = 0 To $aSelected[0] _GUICtrlListBox_DeleteString($idList_1, $i) Next EndFunc ;==>Remove ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GUICtrlListBox_CreateArray ; Description ...: Creates a 1-dimensional array from a listbox. ; Syntax ........: _GUICtrlListBox_CreateArray($hListBox) ; Parameters ....: $hListBox - Control ID/Handle to the control ; Return values .: Success - The array returned is one-dimensional and is made up of the following: ; $aArray[0] = Number of rows ; $aArray[1] = 1st row ; $aArray[2] = 2nd row ; $aArray[n] = nth row ; Author ........: guinness ; Remarks .......: GUICtrlListBox.au3 should be included. ; Example .......: Yes ; =============================================================================================================================== Func _GUICtrlListBox_CreateArray($hListBox) Local $iItemCount = _GUICtrlListBox_GetCount($hListBox) Local $aReturn[$iItemCount + 1] = [$iItemCount] For $i = 0 To $iItemCount - 1 $aReturn[$i + 1] = _GUICtrlListBox_GetText($hListBox, $i) Next Return SetError(Number($aReturn[0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListBox_CreateArray Ofc this is a fast and simple code, with not much error control. But it should give you an idea of how it could be done Cheers /Rex
  7. I know that it's not what you ask for. It's an alternative solution on how to handle multiply selections. Using a ListBox or perhaps a ListView, and allow the user to add the selection to that ListBox/View, and also supply a button (or an double click in the List*) to remove an item. If you want to add/remove a ctrl you can use GUICtrlCreate and GUICtrlDelete, then use winmove to change the size of the GUI. Using the While loop I belive that the ctrls should be created as arrays (Not sure on that, I normally uses on event mode for my GUI's) Cheers /Rex
  8. You could just create a user.js file in the FF user profile dir, and add user_pref("browser.startup.homepage", "www.google.com"); Or search for the "user_pref("browser.startup.homepage", "DEFAULT FF HOMEPAGE");" in prefs.js and replace the default ff homepage. More info here Cheers /Rex
  9. @Docfxit Good to hear that it worked for you, though it's the same exe file as on the official Studio site - so there shouldn't had been any differences in downloading and running the file 🤔, and as I wrote the only "error" I got when dl in a clean win10, was that the publisher couldn't be verified. Cheers /Rex
  10. In a fresh windows 10, I tried to Dl the studio with that edge thingi MS is so proud of and got this. So it seems that MS don't see the studio as a virus. Cheers /Rex
  11. @Docfxit Else you can try from here https://www.dropbox.com/s/7vzd12j1qj7rwy8/ISN Autoit Studio Setup 108.exe?dl=1 Cheers /Rex
  12. I recall that longtime ago a similar question was asked, and several solutions was suggested One of those solutions might work for you Cheers /Rex
  13. I wrote a small count down program some time ago Count Down Days, and shortly after I started using it I found out the I wanted more that one instance of it. So I did some brute force copy ini files, that allowed me to start the program with cmdline - it works and I can have x copy's running, but I would like to just run the program once, and then create multiply countdown GUI's, but the my brain just stopped working, and even I did try to bang my head into the wall, and onto the table it still just would start working again. And now I just have a damn headache 😖 I have rewritten the CDD to use SQLite, and that works swell - it's only that darn multi instance I can't get my brain to figure out a way to do, for me one usage it's not a problem, I can just add to the database, and run CDD with cmd 1. But I would like the program to be user friendly, so the user can add another instance in the settings, and or start a new instance from the menu. My idea was some thing like starting the main GUI in a for to loop, but I couldn't figure out how to handle the countdown and extra instances part. And that is where I hope that some one could point kick me in the right direction, I have spend the last 3 days looking at the monitor and got nowhere, I know the solution is right there with in my reach, my arms is just to short My code so far: (uses cmdline to handle multiply instances), and multiply language is still not implemented. #NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=CDD.ico #AutoIt3Wrapper_Outfile=CDD.exe #AutoIt3Wrapper_Res_Fileversion=0.0.0.0 #AutoIt3Wrapper_Res_HiDpi=Y #AutoIt3Wrapper_Run_After=""d:\Profil\Rex\ISN AutoIt Studio\Projects\Versions Controler\Versions_Controle.exe" "%in%" "%scriptdir%" "%scriptfile%" "%fileversion%"" #AutoIt3Wrapper_Run_After=""d:\Profil\Rex\ISN AutoIt Studio\Projects\Versions Controler\Versions_Controle.exe" "%out%" "%scriptdir%" "%scriptfile%" "%fileversion%"" #AutoIt3Wrapper_Tidy_Stop_OnError=n #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/tl /sf /sv /rsln /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; #INDEX# ======================================================================================================================= ; Title .........: Countdown_Days.au3 ; Script Version : 1.0.0 ; AutoIt Version : 3.3.15.1 - Created with ISN AutoIt Studio v. 1.08 and 1.09 Dev ; Description ...: Countdown a specfic number of days ; Author(s) .....: Rex ; Creation date..: 2019/02/03 ; =============================================================================================================================== ; #CHANGE LOG# ================================================================================================================== ; Changes .......: See project log ; Date ..........: ; =============================================================================================================================== #cs Lang msg handling ; Get the string to handle (All stings should be read into arrays) Local $sString = IniRead('English.lng', 'Settings', 'Msg_DelDef', '') ; Then we split the Title and msg into seperat arrays Local $aMsg = StringRegExp($sString, '{Title}(.*){Msg}(.*)', 1) ; Title would be 0 and msg 1, we also do a Stringformat to handle \r\n (@CRLF) and last we do a stringreplace to replace the {VAR} ; with the war we want it to be replaced with - the stringreplace is only nessary when we habe some var that should be placed inside the ; msgbox, else we dont need it. MsgBox(0, $aMsg[0], StringFormat(StringReplace($aMsg[1], '{VAR}', $aSel[1]))) #ce Lang msg handling #pragma compile(Fileversion, 1.0.0.11) #pragma compile(FileDescription, Countdown to a specific day) #pragma compile(Comments, "Add The days To count down, And the program will countdown, and throw a message / sound") #pragma compile(ProductName, CountDownDays) #pragma compile(ProductVersion, 1.0) #pragma compile(InternalName, "CDD") #pragma compile(LegalCopyright, © Johnny Rex) #pragma compile(OriginalFilename, CDD.exe) ;~ #pragma compile(LegalTrademarks, '"Trademark something, and some text in "quotes" etc...') #pragma compile(CompanyName, 'Rex-IT') #include <Date.au3> #include <ColorConstants.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <String.au3> #include <GuiComboBox.au3> #include <MsgBoxConstants.au3> #include <WinAPIDlg.au3> #include <Sound.au3> #include <GuiListBox.au3> #include <WinAPISysWin.au3> #include <FileConstants.au3> #include <SQLite.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <GuiScrollBars.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Opt('GUIResizeMode', $GUI_DOCKALL) ; To prevent ctrls to move when we add a new event OnAutoItExitRegister('MenuItem_ExitClick') ; To save pos at closedown, if savepos is enabled Global $g_iSecs, $g_iMins, $g_iHours, $g_iDays, $g_iInstance = 0, $g_sDBFile = @ScriptDir & '\Data.db' ; MsgBox Styles Global $g_iMBErr = BitOR($MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONERROR), $g_iMBWarn = BitOR($MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONWARNING) Global $g_iMBInfo = BitOR($MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONINFORMATION), $g_iMBQuest = BitOR($MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONQUESTION) ; GUI Handle Global $hAddEvent, $idAddEvent, $hEditEvent, $idEditEvent, $hDeleteEvent, $idDelEvent, $hSettings Global $idSet_DefEvents, $idSet_EditDef, $idSet_Global, $idSet_Color, $idSet_Instance ConsoleWrite(@CRLF & 'Singleton = ' & _Singleton(@ScriptName) & @CRLF) ; Start SQLite _SQLite_Startup() If @error Then MsgBox($g_iMBErr, "SQLite Error", "SQLite3.dll Can't be Loaded!" & _ @CRLF & 'Is SQLite3 installed on the system?' & @CRLF & 'Or is SQLite3.dll in the root of ' & @ScriptDir & @CRLF & @CRLF & _ 'If not SQLite can be downloaded from https://www.sqlite.org/download.html') Exit -1 EndIf ; Check if the database file exists If Not FileExists(@ScriptDir & '\Data.db') Then ; The database don't exist, so we creates one ; Tell the user that we create a new database, and allow them to cancel the creation If MsgBox(BitOR($g_iMBWarn, $MB_OKCANCEL), 'DataBase', 'No database was found!' & @CRLF & _ 'Create a new DataBase?' & @CRLF & 'If Cancel the program will close!!') = $IDCANCEL Then OnAutoItExitUnRegister('MenuItem_ExitClick') ; Remove the on exit to prevent error Exit EndIf CreateDB() If @error Then MsgBox($g_iMBErr, 'DataBase creation failed', 'An error happend when trying to create the DataBase "Data.db" in ' & @ScriptDir & '\' & _ @CRLF & @CRLF & 'The program will now close!!') OnAutoItExitUnRegister('MenuItem_ExitClick') ; Remove the on exit to prevent error Exit EndIf EndIf ; Get settings ; First we check if the CDD was called with commandline parms If $cmdline[0] = 1 Then ; If called by cmd line we suspect that the user wants to run an extra instance of the CDD ; Convert the cmdline to INT using Number, course we use INT to handle what instance of CDD thats running ; and Number would return 0 on most stings not INT $cmdline[1] = Number($cmdline[1]) If Not $cmdline[1] = 0 Or $cmdline[0] = '' Then $g_iInstance = $cmdline[1] EndIf EndIf ; Create Settings enum's, so we don't have to remember there pos in the array Global Enum $eSet_RowID, $eSet_Inst, $eSet_Max, $eSet_Rem, $eSet_SoundPlay, $eSet_Popup, $eSet_Start, $eSet_Lang, _ $eSet_SoundFile, $eSet_GuiLeft, $eSet_GuiTop, $eSet_Pin Global $g_aSettings = DBHandle('GetSet', $g_iInstance) ; Create enum for the colors Global Enum $eCol_RowID, $eCol_Inst, $eCol_GuiBk, $eCol_DragLbl, $eCol_Name, $eCol_Days0, $eCol_Days1, $eCol_Days2, _ $eCol_Days3, $eCol_DaysLbl, $eCol_Time0, $eCol_Time1, $eCol_Time2, $eCol_Time3, $eCol_TimeColon, $eCol_EventUp, $eCol_EventUpBk Global $g_aColors = DBHandle('GetColors', $g_iInstance) ; Check if the gui should start at last saved position If $g_aSettings[$eSet_Rem] = False Then $g_aSettings[$eSet_GuiLeft] = -1 ; Default Screen center $g_aSettings[$eSet_GuiTop] = -1 ; Default Screen center EndIf ; Enum event columns Global Enum $eEvent_RowID, $eEvent_Inst, $eEvent_Name, $eEvent_Desc, $eEvent_Date, $eEvent_SoundFile, $eEvent_SoundPlay, $eEvent_Pop, $eEvent_Enabled ; Get events Global $g_aEvents = DBHandle('GetEvents', $g_iInstance) DBHandle('CloseDB', '') ; We close the database after last call ; Check if we have any Events If UBound($g_aEvents) = 1 Then ; If we don't have any events, we creates the array with 1 and Null, 1 to be used to create an empty gui ; Null so we know that there isn't any events $g_aEvents[0][0] = 1 $g_aEvents[0][1] = Null EndIf Global $g_idLbl_Days[$g_aSettings[$eSet_Max] + 1], _ $g_idLbl_Hrs[$g_aSettings[$eSet_Max] + 1], _ $g_idLbl_Min[$g_aSettings[$eSet_Max] + 1], _ $g_idLbl_Sec[$g_aSettings[$eSet_Max] + 1], _ $g_idLbl_Event[$g_aSettings[$eSet_Max] + 1] Global $g_iSpace = 80 Global $g_iGuiHeight = ($g_iSpace * UBound($g_aEvents) - 1) + 8 #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hCountdownDays.kxf Global $hCountdownDays = GUICreate("CountDown Days", 136, $g_iGuiHeight, $g_aSettings[$eSet_GuiLeft], _ $g_aSettings[$eSet_GuiTop], $WS_POPUP, $WS_EX_TOOLWINDOW) ; Gui menu Global $hCountdownDayscontext = GUICtrlCreateContextMenu() Global $MenuItem_EventHandling = GUICtrlCreateMenu("Event(s)", $hCountdownDayscontext) Global $MenuItem_AddEvent = GUICtrlCreateMenuItem("Add", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_AddEventClick") Global $MenuItem_EditEvent = GUICtrlCreateMenuItem("Edit", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_EditEventClick") Global $MenuItem_DeleteEvent = GUICtrlCreateMenuItem("Delete", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_DeleteEventClick") Global $MenuItem_Settings = GUICtrlCreateMenuItem("Settings", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_SettingsClick") Global $MenuItem_Pin = GUICtrlCreateMenuItem("Pin in Place", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_PinClick") Global $MenuItem_Exit = GUICtrlCreateMenuItem("Exit", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_ExitClick") GUISetBkColor($g_aColors[$eCol_GuiBk]) Global $idLbl_Move = GUICtrlCreateLabel('', 1, 1, 134, 12, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, $g_aColors[$eCol_DragLbl]) ; Create a label to frame the gui, so it don't look to flat Global $idFrame = GUICtrlCreateLabel('', 0, 0, 136, $g_iGuiHeight, BitOR($SS_SUNKEN, $WS_DISABLED, $SS_SIMPLE)) If $g_aEvents[0][1] = Null Then UpdateGui(False) ; Update Countdown GUI Else UpdateGui(True) ; Update Countdown GUI EndIf ; check if we needs to tick the pin, and disable the Move label If $g_aSettings[$eSet_Pin] = True Then GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) GUICtrlSetState($idLbl_Move, $GUI_DISABLE) EndIf ; Check if we should disable the add event MenuItem If UBound($g_aEvents) - 1 >= $g_aSettings[$eSet_Max] Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) ; Show the CDD Gui GUISetState(@SW_SHOW, $hCountdownDays) #EndRegion ### END Koda GUI section ### ; Start the countdown. Countdown() ; Register the adlib to call the countdown function every sec AdlibRegister("Countdown", 1000) While 1 Sleep(900) WEnd Func MenuItem_AddEventClick() ; Create the GUI #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hAddEvent.kxf $hAddEvent = GUICreate("Add Event", 206, 407, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") $idAddEvent = GUICtrlCreateDummy() ; Create a dumme, we use this to calculate the CtrlID of the Controls created after the dummy GUICtrlCreateLabel("Default Events:", 8, 8, 77, 17) ; This would be dummy + 1 in ID GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetTip(-1, "Saved default events") GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 17) GUICtrlCreateInput("", 8, 72, 185, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event." & @CRLF & "This is the text that will be shown at the gui." & @CRLF _ & "Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 104, 89, 17) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description." & @CRLF _ & "This wil be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlCreateCheckbox("Choose Event date by calendar", 8, 216, 170, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlCreateLabel("Days to event:", 8, 240, 73, 17) GUICtrlCreateInput("", 8, 256, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event") GUICtrlCreateLabel("Time of event", 112, 240, 69, 17) GUICtrlCreateDate('', 112, 256, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') ; Set time style GUICtrlCreateLabel("Event date:", 8, 240, 59, 17) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateDate('', 8, 256, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') ; Set Date and Time style GUICtrlSetTip(-1, "The end date of the event") GUICtrlSetState(-1, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Diasbled and hidden yy default GUICtrlCreateLabel("Sound to play:", 8, 280, 72, 17) GUICtrlCreateInput($g_aSettings[$eSet_SoundFile], 8, 296, 160, 21, $ES_READONLY) ; Default sound to play at event end GUICtrlSetTip(-1, $g_aSettings[$eSet_SoundFile]) GUICtrlCreateButton("...", 174, 296, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 8, 328, 73, 17) CbSetState(-1, $g_aSettings[$eSet_SoundPlay]) GUICtrlCreateCheckbox("Popup", 88, 328, 49, 17) CbSetState(-1, $g_aSettings[$eSet_Popup]) GUICtrlCreateCheckbox("Save as default event", 8, 352, 124, 17) GUICtrlSetTip(-1, "Saves the event as a default event, that later can be choosen from the dropdown") GUICtrlCreateButton("&Add event", 8, 376, 75, 21) GUICtrlSetTip(-1, "Adds the events and closes the add event gui") GUICtrlSetOnEvent(-1, "idBtn_AddEventClick") GUICtrlCreateButton("&Close", 120, 376, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") #EndRegion ### END Koda GUI section ### ; Add default evnets to dropdown Local $aDefEvents = DBHandle('GetDefEvents', $g_iInstance) If IsArray($aDefEvents) Then For $i = 0 To UBound($aDefEvents) - 1 ; Add the defaults to the combo and revert the name from hex to string. GUICtrlSetData($idAddEvent + 2, $aDefEvents[$i][$eEvent_Name]) Next EndIf ; Set focus to the Event Name input GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) ; Show the gui GUISetState(@SW_SHOW, $hAddEvent) EndFunc ;==>MenuItem_AddEventClick Func MenuItem_DeleteEventClick() ; Create the GUI #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf $hDeleteEvent = GUICreate("Delete Event", 355, 214, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") $idDelEvent = GUICtrlCreateDummy() GUICtrlCreateLabel("Choose event to delete:", 8, 8, 122, 16) GUICtrlCreateListView("rowid|Event name|End date|Enabled", 8, 24, 338, 150, BitOR($LVS_NOSORTHEADER, $WS_VSCROLL), _ BitOR($LVS_EX_FLATSB, $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 10) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 120) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 56) _GUICtrlListView_HideColumn(-1, 0) ; Hides the rowid colum GUICtrlSetTip(-1, "Select event to delete") GUICtrlCreateButton("&Delete", 8, 184, 75, 21) GUICtrlSetTip(-1, "Deletes selected event") GUICtrlSetOnEvent(-1, "idBtn_EventDeleteClick") GUICtrlCreateButton("&Close", 272, 184, 75, 21) GUICtrlSetTip(-1, "Closes the add event, without saving the event.") GUICtrlSetOnEvent(-1, "hWnd_Close") #EndRegion ### END Koda GUI section ### Local $aEvents = DBHandle('GetAllEvents', $g_iInstance) If IsArray($aEvents) Then For $i = 1 To UBound($aEvents) - 1 GUICtrlCreateListViewItem($aEvents[$i][$eEvent_RowID] & '|' & $aEvents[$i][$eEvent_Name] & '|' & _ $aEvents[$i][$eEvent_Date] & '|' & $aEvents[$i][$eEvent_Enabled], $idDelEvent + 2) Next EndIf If _GUICtrlListView_GetItemCount($idDelEvent + 2) < 7 Then _GUICtrlListView_SetColumnWidth($idDelEvent + 2, 1, 158) GUISetState(@SW_SHOW, $hDeleteEvent) EndFunc ;==>MenuItem_DeleteEventClick Func MenuItem_EditEventClick() ; Create GUI #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf $hEditEvent = GUICreate("Edit Event", 292, 429, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") $idEditEvent = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, 'EventListView') GUICtrlCreateLabel("Choose event to edit:", 8, 8, 110, 17) GUICtrlCreateListView("rowid|Name|End date", 8, 24, 276, 94, BitOR($LVS_NOSORTHEADER, $WS_HSCROLL), _ BitOR($LVS_EX_FLATSB, $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 10) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 140) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 114) GUICtrlSetTip(-1, "Double click to select the event") _GUICtrlListView_HideColumn(-1, 0) ; Hides the rowid colum GUICtrlCreateLabel("Event Name:", 8, 128, 66, 17) GUICtrlCreateInput("", 8, 144, 275, 21) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event. This is the text that will be shown at the gui. Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 176, 89, 17) GUICtrlCreateEdit("", 8, 192, 275, 57, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description. This will be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateCheckbox("Choose new event date by calender", 8, 264, 200, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlSetState(-1, BitOR($GUI_DISABLE, $GUI_CHECKED)) GUICtrlCreateLabel("Days to event:", 8, 288, 73, 17) GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE)) GUICtrlCreateInput("", 8, 304, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event, time will be from the time the event is added") GUICtrlCreateLabel("Time of event", 112, 288, 69, 17) GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE)) GUICtrlCreateDate('', 112, 304, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') GUICtrlSetTip(-1, "Time of the event") GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_DISABLE)) GUICtrlCreateLabel("Event date:", 8, 288, 59, 17) GUICtrlCreateDate('', 8, 304, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetTip(-1, "Choose the end date of the event") GUICtrlCreateLabel("Sound to play:", 8, 328, 72, 17) GUICtrlCreateInput("", 8, 344, 250, 21, $ES_READONLY) GUICtrlCreateButton("...", 264, 344, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateCheckbox("Play sound", 8, 376, 73, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateCheckbox("Popup", 88, 376, 49, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateCheckbox("Enabled", 144, 376, 60, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetTip(-1, "Enables or disables the event, if disabled it don't show in the countdown gui") GUICtrlCreateButton("&Update", 8, 400, 75, 21) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetTip(-1, "Updates the selected event") GUICtrlSetOnEvent(-1, "idBtn_UpdateEventClick") GUICtrlCreateButton("&Close", 210, 400, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") #EndRegion ### END Koda GUI section ### ; Add events to the listView Local $aEvents = DBHandle('GetAllEvents', $g_iInstance) If IsArray($aEvents) Then For $i = 1 To UBound($aEvents) - 1 GUICtrlCreateListViewItem($aEvents[$i][$eEvent_RowID] & '|' & $aEvents[$i][$eEvent_Name] & '|' & $aEvents[$i][$eEvent_Date], _ $idEditEvent + 2) Next EndIf If _GUICtrlListView_GetItemCount($idEditEvent + 2) < 3 Then _GUICtrlListView_SetColumnWidth($idEditEvent + 2, 1, 158) ; Show the gui GUISetState(@SW_SHOW, $hEditEvent) ; Catch double click in Edit event listview GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") EndFunc ;==>MenuItem_EditEventClick Func MenuItem_SettingsClick() #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hSettings.kxf $hSettings = GUICreate("Settings", 523, 478, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") $idSet_DefEvents = GUICtrlCreateGroup("Default events:", 8, 8, 201, 185) GUICtrlCreateListView("RowID|Name", 16, 24, 186, 134, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_NOCOLUMNHEADER, $LVS_NOSORTHEADER), BitOR($WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 0) ; Hide the RowID colum GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 170) GUICtrlSetTip(-1, "Default events that, can be picked from add event.") GUICtrlCreateRadio("Edit", 16, 168, 40, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlSetTip(-1, "Edit selected event") GUICtrlCreateRadio("Delete", 64, 168, 60, 17) GUICtrlSetTip(-1, "Delete the selected event") GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateButton("Edit", 144, 168, 50, 20) GUICtrlSetTip(-1, "Deletes the selected Default event") GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateGroup("", -99, -99, 1, 1) $idSet_Instance = GUICtrlCreateGroup("Instance", 8, 200, 201, 49) GUICtrlCreateInput("0", 16, 217, 41, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY, $ES_NUMBER)) GUICtrlCreateUpdown(-1) GUICtrlSetLimit(-1, 3, 0) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateRadio("Add", 64, 218, 40, 17) GUICtrlSetTip(-1, 'Adds a nother Instance to the database') GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateRadio("Remove", 106, 218, 60, 17) GUICtrlSetTip(-1, 'Removes an Instance from the DataBase,' & @CRLF & 'this will also remove all events added inder that Instance') GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateButton("OK", 172, 217, 29, 20) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateGroup("", -99, -99, 1, 1) $idSet_Global = GUICtrlCreateGroup("Global settings:", 8, 256, 201, 185) GUICtrlCreateLabel("Max number of events:", 16, 272, 112, 21, $SS_CENTERIMAGE) GUICtrlSetTip(-1, "Max number of events." & @CRLF & "On a 1920x1080 Screen the max would be aprox 13 events.") GUICtrlCreateInput($g_aSettings[$eSet_Max], 138, 272, 21, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) GUICtrlSetTip(-1, "Max number of events." & @CRLF & "On a 1920x1080 Screen the max would be aprox 13 events.") GUICtrlCreateCheckbox("Remember position", 16, 296, 110, 17) CbSetState(-1, $g_aSettings[$eSet_Rem]) GUICtrlSetTip(-1, "When countdown is closed" & @CRLF & " it saves the position it was placed, and starts at that position.") GUICtrlCreateCheckbox("Play Sound", 128, 296, 74, 17) CbSetState(-1, $g_aSettings[$eSet_SoundPlay]) GUICtrlSetTip(-1, "Plays a sound when the event time is up.") GUICtrlCreateCheckbox("Show popup", 16, 320, 80, 17) CbSetState(-1, $g_aSettings[$eSet_Popup]) GUICtrlSetTip(-1, "Shows a popup windows, when the event time is up." & @CRLF & "The content of the popup windows will be the event descrption.") GUICtrlCreateCheckbox("Start with system", 104, 320, 98, 17) CbSetState(-1, $g_aSettings[$eSet_Start]) GUICtrlSetTip(-1, "Start the program with windows") GUICtrlCreateLabel("Language:", 16, 344, 55, 17) GUICtrlCreateCombo($g_aSettings[$eSet_Lang], 16, 360, 185, 21, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetTip(-1, 'The language to use for menus, lables, buttons ect.') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Default alarm sound:", 16, 392, 101, 17) GUICtrlCreateInput($g_aSettings[$eSet_SoundFile], 16, 408, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip(-1, "Default sound to play when the event timeis up." & @CRLF & $g_aSettings[$eSet_SoundFile]) GUICtrlCreateButton("...", 184, 408, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateGroup("", -99, -99, 1, 1) $idSet_Color = GUICtrlCreateGroup("Change Colors:", 216, 8, 297, 217) GUICtrlCreateLabel("GUI BkGround", 224, 24, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'The background color of the GUI') GUICtrlCreateButton("", 336, 24, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_GuiBk]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("GUI Drag label:", 224, 48, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'Color of the drag label') GUICtrlCreateButton("", 336, 48, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_DragLbl]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Event name:", 224, 72, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'Color of the Event text') GUICtrlCreateButton("", 336, 72, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Name]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Days default:", 224, 96, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When more that 15 days left') GUICtrlCreateButton("", 336, 96, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Days0]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Days 5 to 0:", 224, 120, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When between 5 and 0 days left') GUICtrlCreateButton("", 336, 120, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Days1]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Days 10 to 6:", 224, 144, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When between 10 and 6 days left') GUICtrlCreateButton("", 336, 144, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Days2]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Days 15 to 11:", 224, 168, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When between 15 to 11 days left') GUICtrlCreateButton("", 336, 168, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Days3]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Days label:", 224, 192, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'Color of the static label "Days"') GUICtrlCreateButton("", 336, 192, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_DaysLbl]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Time default:", 376, 24, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When more than 0 days left') GUICtrlCreateButton("", 488, 24, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Time0]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Time 6 to 0:", 376, 48, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When 0 days and between 6 and 0 hours left') GUICtrlCreateButton("", 488, 48, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Time1]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Time 12 to 7:", 376, 72, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When 0 days and between 12 to 7 hours left') GUICtrlCreateButton("", 488, 72, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Time2]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Time 23 to 13:", 376, 96, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'When 0 days and between 23 and 13 hours left') GUICtrlCreateButton("", 488, 96, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_Time3]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Time colon:", 376, 120, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, "The static label ':' between hour, min and sec") GUICtrlCreateButton("", 488, 120, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_TimeColon]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Event up:", 376, 144, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'Event name text color when the event time is up') GUICtrlCreateButton("", 488, 144, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_EventUp]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateLabel("Event up BkGround:", 376, 168, 110, 20, $SS_CENTERIMAGE) GUICtrlSetTip(-1, 'Background color of event name, when time is up') GUICtrlCreateButton("", 488, 168, 20, 20) GUICtrlSetBkColor(-1, $g_aColors[$eCol_EventUpBk]) GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateButton("Default", 432, 192, 75, 20) GUICtrlSetTip(-1, "Set the colors to default") GUICtrlSetOnEvent(-1, 'Click_Settings') GUICtrlCreateGroup("", -99, -99, 1, 1) $idSet_EditDef = GUICtrlCreateGroup("Edit default event:", 216, 232, 297, 209) GUICtrlCreateLabel("Event name:", 224, 248, 64, 21, $SS_CENTERIMAGE) GUICtrlCreateInput("", 288, 248, 137, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Days:", 432, 248, 31, 20, $SS_CENTERIMAGE) GUICtrlCreateInput("", 464, 248, 41, 21) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Event description:", 224, 272, 89, 17) GUICtrlCreateEdit("", 224, 288, 281, 81, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Alarm sound:", 224, 384, 65, 20, $SS_CENTERIMAGE) GUICtrlCreateInput('', 288, 384, 193, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateButton("...", 488, 384, 21, 21) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 224, 412, 72, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateCheckbox("Show popup", 304, 412, 80, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("", 464, 416, 10, 17) ; Hidden label to hold the row id of the def event thats been edited GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateButton("OK", 8, 448, 75, 21) GUICtrlSetOnEvent(-1, "Click_Settings") GUICtrlCreateButton("Close", 440, 448, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") #EndRegion ### END Koda GUI section ### ; Update the gui with info's from the settings file, or if no settings file exists, with defaults ; Add default evnets to Listbox (The events that is saved, and can be loaded in add event) Local $aDefEvents = DBHandle('GetDefEvents', '') If IsArray($aDefEvents) Then ; If it's an array we continue For $i = 0 To UBound($aDefEvents) - 1 ; Add the defaults to the listbox and convert the name from hex to string. GUICtrlCreateListViewItem($aDefEvents[$i][0] & '|' & $aDefEvents[$i][1], $idSet_DefEvents + 1) Next EndIf ; Check if the Remember, playsound, popup and Start with windows is enabled in settings CbSetState($idSet_Global + 3, $g_aSettings[$eSet_Rem]) CbSetState($idSet_Global + 4, $g_aSettings[$eSet_SoundPlay]) CbSetState($idSet_Global + 5, $g_aSettings[$eSet_Popup]) CbSetState($idSet_Global + 6, $g_aSettings[$eSet_Start]) ; Show the gui GUISetState(@SW_SHOW, $hSettings) EndFunc ;==>MenuItem_SettingsClick Func MenuItem_ExitClick() ; We only run this function Once Local Static $bRunned = True If $bRunned = True Then $bRunned = False ; Check if the program should save it's poition If $g_aSettings[$eSet_Rem] = True Then SetPos() EndIf ; Delete the CDD GUI GUIDelete($hCountdownDays) ; VACUUM the DataBase DBHandle('VACUUM', '') ; Close Sql _SQLite_Close() EndIf Exit EndFunc ;==>MenuItem_ExitClick Func SetPos() ; get the position of the GUI Local $aPos = WinGetPos($hCountdownDays) Local $aPos2D[3][2] = [[$g_aSettings[$eSet_RowID], $g_aSettings[$eSet_RowID]], ['PosLeft', $aPos[0]], ['PosTop', $aPos[1]]] ; Update the position in the DataBase DBHandle('UpdatePos', $aPos2D) ; Update the Settings array $g_aSettings[$eSet_GuiLeft] = $aPos[0] $g_aSettings[$eSet_GuiTop] = $aPos[1] EndFunc ;==>SetPos Func MenuItem_PinClick() ; Get state of MenuItem Pin in place ; If the pin is enabled, the gui can't be moved ; When pinned Save last pos is automaticly enabled If BitAND(GUICtrlRead($MenuItem_Pin), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($MenuItem_Pin, $GUI_UNCHECKED) $g_aSettings[$eSet_Pin] = False ; Update the var DBHandle('UpdateSingleSet', 'Pin|False') GUICtrlSetState($idLbl_Move, $GUI_ENABLE) ; Enable the label, this allows the gui to be moved Else GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) $g_aSettings[$eSet_Pin] = True ; Update the var $g_aSettings[$eSet_Rem] = True ; Enables remember last pos DBHandle('UpdateSingleSet', 'Pin|True') DBHandle('UpdateSingleSet', 'Remember|True') SetPos() DBHandle('CloseDB', '') GUICtrlSetState($idLbl_Move, $GUI_DISABLE) ; Disable the label, preventing the gui to be moved EndIf EndFunc ;==>MenuItem_PinClick Func hWnd_Close() ; Delete the gui GUIDelete(@GUI_WinHandle) ; Close the database DBHandle('CloseDb', '') EndFunc ;==>hWnd_Close Func Click_Main() ; only one thing calls this function, and that a event label ; And all we chould do here is to kil the playing sound ; Create a static to prevent further clicks (due to bug in setonevent remove) Local Static $iCtrlID = 0 If $iCtrlID <> @GUI_CtrlId Then ConsoleWrite(@CRLF & 'Label Click = ' & @GUI_CtrlId & @CRLF) $iCtrlID = @GUI_CtrlId SoundPlay('') GUICtrlSetOnEvent(@GUI_CtrlId, '') ; And this don't work due to a bug in autoit :'( EndIf EndFunc ;==>Click_Main Func Click_Settings() ; Handle Button, Checkbox, Radios etc. clicks ; First we get the Winhandle of the win in where the click came from ConsoleWrite(@CRLF & 'Id = ' & @GUI_CtrlId & @CRLF) Switch @GUI_CtrlId Case $idSet_DefEvents + 2 ; Default events radio Edit ; Set butten text Edit GUICtrlSetData($idSet_DefEvents + 4, 'Edit') Case $idSet_DefEvents + 3 ; Default events Radio delete ; Set button text Delete GUICtrlSetData($idSet_DefEvents + 4, 'Delete') Case $idSet_DefEvents + 4 ; Default evnets Button Edit/Remove ; Check that an event has been chosen If GUICtrlRead($idSet_DefEvents + 1) Then ; Read the selected event, and split the read info where row 0 would be the rowid, and row 1 the Name of the event Local $aSel = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($idSet_DefEvents + 1)), 1), '|', $STR_NOCOUNT) ; Check if we should Delete or edit the selected event Switch GUICtrlRead($idSet_DefEvents + 4) Case 'Edit' Local $aData = DBHandle('GetSingleDefEvent', $aSel[0]) ; Update the edit event ctrls GUICtrlSetData($idSet_EditDef + 2, $aData[0]) ; Event Name GUICtrlSetData($idSet_EditDef + 4, $aData[2]) ; Days GUICtrlSetData($idSet_EditDef + 6, $aData[1]) ; Description GUICtrlSetData($idSet_EditDef + 8, $aData[3]) ; Sound file CbSetState($idSet_EditDef + 10, StringToType($aData[4])) ; Play Sound CbSetState($idSet_EditDef + 11, StringToType($aData[5])) ; Show popup ; Set rowid of the event we just edited, to the hidden label - So we can update it later wehen/if the ok button is hit GUICtrlSetData($idSet_EditDef + 12, $aSel[0]) ; Hidden label to hold rowid of the edited event ; And enable the controls. For $i = 2 To 11 GUICtrlSetState($idSet_EditDef + $i, $GUI_ENABLE) Next Case 'Delete' ; If the user clicks Delete ; First we warn, that the selected will be deletede, and can't be restored Local $iStyle = BitOR($MB_ICONWARNING, $MB_SETFOREGROUND, $MB_TOPMOST, $MB_SYSTEMMODAL, $MB_YESNO) If MsgBox($iStyle, 'Delete default event', 'The default event: ' & $aSel[1] & @CRLF & "Will be delete, and can't be restored!" & _ @CRLF & @CRLF & 'Do you want to continue?') = $IDNO Then Return ; If msg = yes then remove the item from the database and listview DBHandle('DelSingleDefEvent', $aSel[0]) DBHandle('CloseDB', '') _GUICtrlListView_DeleteItemsSelected($idSet_DefEvents + 1) EndSwitch EndIf Case $idSet_Instance + 2 ; Instance Updown ConsoleWrite(@CRLF & 'Read text from ctrlid 2 = ' & GUICtrlRead(@GUI_CtrlId - 1) & @CRLF) Case $idSet_Instance + 3 ; Instance Radio Add ConsoleWrite(@CRLF & 'Read text from ctrlid 3= ' & GUICtrlGetState(@GUI_CtrlId) & @CRLF) Case $idSet_Instance + 4 ; Instance Radio Delete ConsoleWrite(@CRLF & 'Read text from ctrlid 4= ' & GUICtrlGetState(@GUI_CtrlId) & @CRLF) Case $idSet_Instance + 5 ; Instance button OK ConsoleWrite(@CRLF & 'Read text from ctrlid 5= ' & GUICtrlRead(@GUI_CtrlId) & @CRLF) Case $idSet_Color + 2 To $idSet_Color + 30 ; Colors Colorpicker buttons Local $dColor = _ChooseColor(2, 0, 0, @GUI_WinHandle) If Not @error Then ; Set the background color of the button, to show the user what color was choosen GUICtrlSetBkColor(@GUI_CtrlId, $dColor) ; Set text color to same as background, so we can hide the text we add GUICtrlSetColor(@GUI_CtrlId, $dColor) ; Set the text size to 1, so the button don't look funny when we add text to it GUICtrlSetFont(@GUI_CtrlId, 1) ; Write the colorcode as text on the button, we do this so when we saves the settings ; we can read the color code from the button GUICtrlSetData(@GUI_CtrlId, $dColor) EndIf Case $idSet_Color + 31 ; Colors Button Default ; Set default colors Local $aCol = StringSplit('0x4E4E4E|0x808080|0xFFFFFF|0x000000|0xFF0000|0xFFFF00|0x008000|0x000000|0x000000|' & _ '0xFF0000|0xFFFF00|0x008000|0x000000|0xFF0000|0xFFFF00', '|', $STR_NOCOUNT) Local $y = 0 For $i = 2 To 30 Step 2 ; Set the background color of the button, to show the user what color was choosen GUICtrlSetBkColor($idSet_Color + $i, $aCol[$y]) ; Set text color to same as background, so we can hide the text we add GUICtrlSetColor($idSet_Color + $i, $aCol[$y]) ; Set the text size to 1, so the button don't look funny when we add text to it GUICtrlSetFont($idSet_Color + $i, 1) ; Write the colorcode as text on the button, we do this so when we saves the settings ; we can read the color code from the button GUICtrlSetData($idSet_Color + $i, $aCol[$y]) $y += 1 Next Case $idSet_EditDef + 14 ; Settings OK button ; Read infos and update the settings. ; Get maxEvents Local $iMax = GUICtrlRead($idSet_Global + 2) If $iMax = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Max number of events', _ "The input Max number of events is empty, but it shouldn't be" & @CRLF & 'Please type number of max allowed events!!') GUICtrlSetState($idSet_Global + 2, $GUI_FOCUS) Return EndIf ; Get Colors Local $y = 0 For $i = 2 To 30 Step 2 ; Read the selected color by reading the button text Local $dBtnColor = GUICtrlRead($idSet_Color + $i) ; Check if the button has any text, if so we update the color array with the new color If $dBtnColor <> '' Then $g_aColors[$y] = $dBtnColor $y += 1 Next ; Update Settings Array ; Rember last position $g_aSettings[$eSet_Rem] = (GUICtrlRead($idSet_Global + 3) = $GUI_CHECKED) ? True : False ; Play sound $g_aSettings[$eSet_SoundPlay] = (GUICtrlRead($idSet_Global + 4) = $GUI_CHECKED) ? True : False ; Show popup $g_aSettings[$eSet_Popup] = (GUICtrlRead($idSet_Global + 5) = $GUI_CHECKED) ? True : False ; Start with windows $g_aSettings[$eSet_Start] = (GUICtrlRead($idSet_Global + 6) = $GUI_CHECKED) ? True : False ; Sound file $g_aSettings[$eSet_SoundFile] = GUICtrlRead($idSet_Global + 10) ; Check if the program should rember it's last position If GUICtrlRead($idSet_Global + 3) = $GUI_CHECKED Then SetPos() EndIf ; Check if the program should start with windows If GUICtrlRead($idSet_Global + 6) = $GUI_CHECKED Then RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CDD_' & $g_iInstance, 'REG_SZ', @ScriptFullPath & ' ' & $g_iInstance) Else RegDelete('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CDD_' & $g_iInstance) EndIf ; Check if an event has been edited Local $iRowID = GUICtrlRead($idSet_EditDef + 12) If $iRowID <> '' Then Local $aDefEvents[7][2] $aDefEvents[0][0] = $iRowID $aDefEvents[0][1] = '' $aDefEvents[1][0] = 'Name' $aDefEvents[1][1] = GUICtrlRead($idSet_EditDef + 2) $aDefEvents[2][0] = 'Desc' $aDefEvents[2][1] = GUICtrlRead($idSet_EditDef + 6) $aDefEvents[3][0] = 'Days' $aDefEvents[3][1] = GUICtrlRead($idSet_EditDef + 4) $aDefEvents[4][0] = 'Soundfile' $aDefEvents[4][1] = GUICtrlRead($idSet_EditDef + 8) $aDefEvents[5][0] = 'PlaySound' $aDefEvents[5][1] = (GUICtrlRead($idSet_EditDef + 10) = $GUI_CHECKED) ? True : False $aDefEvents[6][0] = 'PopUp' $aDefEvents[6][1] = (GUICtrlRead($idSet_EditDef + 11) = $GUI_CHECKED) ? True : False ; Update event in DataBase DBHandle('UpdateDefEvent', $aDefEvents) EndIf ; Set GUI background color GUISetBkColor($g_aColors[$eCol_GuiBk], $hCountdownDays) ; Set the color of the drag lable GUICtrlSetBkColor($idLbl_Move, $g_aColors[$eCol_DragLbl]) ; Update the gui UpdateGui(False) ; And finaly update the DataBase DBHandle('UpdateSet', '') DBHandle('CloseDB', '') ; Delete the GUI GUIDelete($hSettings) EndSwitch EndFunc ;==>Click_Settings Func idCb_ChoseDateClick() ; Handel the Choose by date checkbox for either Add or Edit event gui ; First we check if it's Add or Edit event gui that is asking Switch @GUI_WinHandle ; The handle of the current gui Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent EndSwitch ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($iCtrlID + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Hide, disable and clear days and time input / label GUICtrlSetState($iCtrlID + 8, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the input Days to event GUICtrlSetData($iCtrlID + 9, '') ; Clear the input Days to event GUICtrlSetState($iCtrlID + 10, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hides the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the TimePicker Time to event ; Show date picker and lable GUICtrlSetState($iCtrlID + 12, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the Date time picker Case False ; Hide, disable and clear date picker and label GUICtrlSetState($iCtrlID + 12, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the Date time picker ; Enable, show and set time input / labels GUICtrlSetState($iCtrlID + 8, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Shows the Input Days to event GUICtrlSetState($iCtrlID + 10, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Shows the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show time picker EndSwitch EndFunc ;==>idCb_ChoseDateClick Func idBtn_AddEventClick() ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idAddEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) Return EndIf ; Handel state of checkbox choose event date by calendar Switch (GUICtrlRead($idAddEvent + 7) = $GUI_CHECKED) ? True : False Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idAddEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idAddEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idAddEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idAddEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch Local $sEvent = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC ; We use this to prevent events with same SectionNames in the ini file. ; Create an array to hold the Event values Local $aValues[8] $aValues[0] = $g_iInstance $aValues[1] = $sReadName ; Event Name $aValues[2] = StringReplace(GUICtrlRead($idAddEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3] = StringRegExpReplace($sDTS, "(\d{4})/(\d{2})/(\d{2})(.*)", "$1-$2-$3$4", 0) ; Event end date $aValues[4] = GUICtrlRead($idAddEvent + 15) ; Get sound to play from input sound to play $aValues[5] = (GUICtrlRead($idAddEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6] = (GUICtrlRead($idAddEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7] = 'True' ; The Event is Enabled by default DBHandle('AddEvent', $aValues) ; Get state of save as default checkbox If GUICtrlRead($idAddEvent + 19) = $GUI_CHECKED Then ; We don't save all the info, only Days to Event, Sound to play, To play o not play the sound and to show or not to show the popup ; Trim the array from unneeded data _ArrayDelete($aValues, '0;7') ; Remove Instance and Enabled ; Get the amount of days to event +1 course the cal is only returing whole days and the event will be in x days and 23:59:xx sec ; There for we needs to ad +1, so it will correspond to the amount of days th euser might have entered in Days to Event $aValues[2] = _DateDiff('D', _NowCalc(), $sDTS) + 1 DBHandle('AddDefEvent', $aValues) ;~ IniWriteSection($g_sSetFile, _StringToHex(GUICtrlRead($idAddEvent + 4)), $aValues) ; Write the info to Settings file EndIf hWnd_Close() ; Close the gui If $g_aEvents[0][1] = Null Then UpdateGui(True) ; Update Countdown GUI with Msg Else UpdateGui(False) ; Update Countdown GUI without msg EndIf EndFunc ;==>idBtn_AddEventClick Func idBtn_UpdateEventClick() ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idEditEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idEditEvent + 4, $GUI_FOCUS) Return EndIf ; Handel state of checkbox Switch (GUICtrlRead($idEditEvent + 7) = $GUI_CHECKED) ? True : False Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idEditEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idEditEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idEditEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idEditEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch ; Create an array to hold the Event values Local $aValues[8][2] $aValues[0][0] = _GUICtrlListView_GetItemText($idEditEvent + 2, Int(GUICtrlRead($idEditEvent))) ; RowID to update $aValues[0][1] = '' $aValues[1][0] = 'Name' $aValues[1][1] = $sReadName ; Event Name $aValues[2][0] = 'Desc' $aValues[2][1] = StringReplace(GUICtrlRead($idEditEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3][0] = 'EndDate' $aValues[3][1] = StringRegExpReplace($sDTS, "(\d{4})/(\d{2})/(\d{2})(.*)", "$1-$2-$3$4") ; Event end date $aValues[4][0] = 'SoundFile' $aValues[4][1] = GUICtrlRead($idEditEvent + 15) ; Get sound to play from input sound to play $aValues[5][0] = 'PlaySound' $aValues[5][1] = (GUICtrlRead($idEditEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6][0] = 'PopUp' $aValues[6][1] = (GUICtrlRead($idEditEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7][0] = 'Enabled' $aValues[7][1] = (GUICtrlRead($idEditEvent + 19) = $GUI_CHECKED) ? True : False ; If enabled or not enabled ; Update the DataBase with the new event data DBHandle('UpdateEvent', $aValues) ; And close the database DBHandle('CloseDB', '') GUISwitch($hEditEvent) ; Close the Edit event gui hWnd_Close() ; Update the CDD GUI using False, this will tricker the del ctrls to recreate the gui with the updated info UpdateGui(False) EndFunc ;==>idBtn_UpdateEventClick Func idBtn_EventDeleteClick() ; Deletes the selected Event from the Events.ini file and if it's current active in the CountDown GUI ; refreshes the gui to remove it from that also ; Get the selected Event data ; $aData[1] = RowID, [2] = Name, [3] = End Date and [4] = Enabled (True/False) Local $aData = StringSplit(StringTrimRight(GUICtrlRead(GUICtrlRead($idDelEvent + 2)), 1), '|') If @error Then Return SetError(-1) EndIf ; Then we warn the user that the event will be deletede If MsgBox(BitOR($MB_YESNO, $MB_TOPMOST, $MB_SETFOREGROUND, $MB_ICONWARNING), 'Delete Event', 'The Event: "' & $aData[2] & '"' & @CRLF & _ 'with end date: "' & $aData[3] & '"' & @CRLF & 'will be deletede!' & @CRLF & @CRLF & 'Do you want to continue?') = $IDNO Then Return ; Delete the event from DataBase DBHandle('DelEvent', $aData[1]) DBHandle('CloseDB', '') ; Check if the event is active in the CountDownGUI, by checking if it's located in the Event array. ; We search for the rowid in the aEvents array, at column 0, and if found we updates the gui ; If the deletede event was Enabled we upadte the GUI If StringToType($aData[4]) = True Then UpdateGui(False) ; Check if Max events is lessere that current enabled events If UBound($g_aEvents) - 1 < $g_aSettings[$eSet_Max] Then GUICtrlSetState($MenuItem_AddEvent, $GUI_ENABLE) EndFunc ;==>idBtn_EventDeleteClick Func idBtn_SoundBrowseClick() ; Sound file browser ; Display an open dialog to select a list of file(s). Local $iExStyle = BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST) Local $sAudioFile = _WinAPI_OpenFileDlg('', @WorkingDir, 'Audio (*.wav;*.mp3)', 1, '', '', $iExStyle) ; We only add if there is something to add If $sAudioFile <> '' Then GUICtrlSetData(@GUI_CtrlId - 1, $sAudioFile) GUICtrlSetTip(@GUI_CtrlId - 1, $sAudioFile) EndIf EndFunc ;==>idBtn_SoundBrowseClick Func EventListView() ; Handle Edit event ListView double clicks ; When a user double clicks on an item in the listview, the WM_NOTIFY sends item index ; to the $idEditEvent dummy ; Error handle Local $sitem = _GUICtrlListView_GetItemText($idEditEvent + 2, Int(GUICtrlRead($idEditEvent))) If $sitem = '' Then Return SetError(-1) ; Get Event data from the DataBase Local $aData = DBHandle('GetSingleEvent', $sitem) ; Set data to gui ; Add the data to the inputs GUICtrlSetData($idEditEvent + 4, $aData[1]) ; Add the name to Event Name input GUICtrlSetData($idEditEvent + 6, $aData[2]) ; Add Description GUICtrlSetData($idEditEvent + 13, $aData[3]) ; Add end date of event GUICtrlSetData($idEditEvent + 15, $aData[4]) ; Add the sound GUICtrlSetTip($idEditEvent + 15, $aData[4]) ;Update the state of the checkboxes CbSetState($idEditEvent + 17, StringToType($aData[5])) ; PlaySound checkbox CbSetState($idEditEvent + 18, StringToType($aData[6])) ; Popup Checkbox CbSetState($idEditEvent + 19, StringToType($aData[7])) ; Enabled checkbox ; Enables controls GUICtrlSetState($idEditEvent + 4, $GUI_ENABLE) ; Event name GUICtrlSetState($idEditEvent + 6, $GUI_ENABLE) ; Event description GUICtrlSetState($idEditEvent + 7, $GUI_ENABLE) ; Checkbox choose by date GUICtrlSetState($idEditEvent + 13, $GUI_ENABLE) ; Date picker GUICtrlSetState($idEditEvent + 15, $GUI_ENABLE) ; Sound to play GUICtrlSetState($idEditEvent + 16, $GUI_ENABLE) ; Button Sound Browse GUICtrlSetState($idEditEvent + 17, $GUI_ENABLE) ; Checkbox play sound GUICtrlSetState($idEditEvent + 18, $GUI_ENABLE) ; Checkbox Popup GUICtrlSetState($idEditEvent + 19, $GUI_ENABLE) ; Checkbox Enabled GUICtrlSetState($idEditEvent + 20, $GUI_ENABLE) ; Update button EndFunc ;==>EventListView Func idCombo_EventsChange() ; Here we handle the combo changes for Add events ; First we read the combo Local $sRead = GUICtrlRead($idAddEvent + 2) ; Now we get the default event data from the DataBase, using the index +1 of the selected event Local $aData = DBHandle('GetSingleDefEvent', _GUICtrlComboBox_GetCurSel($idAddEvent + 2) + 1) _ArrayDisplay($aData, 'Selected in combo') ; Close the DataBase DBHandle('CloseDB', '') ; Add the data to the inputs GUICtrlSetData($idAddEvent + 4, $aData[0]) ; Add Name of event to input GUICtrlSetData($idAddEvent + 6, $aData[1]) ; Add Description to the edit GUICtrlSetData($idAddEvent + 9, $aData[2]) ; Add number of days to input GUICtrlSetData($idAddEvent + 15, $aData[3]) ; Add sound to input GUICtrlSetTip($idAddEvent + 15, $aData[3]) ; Set sound tip (to show full path on hover) ; Set the state of Soundplay CbSetState($idAddEvent + 17, StringToType($aData[4])) ; Set the state of popup checkbox CbSetState($idAddEvent + 18, StringToType($aData[5])) EndFunc ;==>idCombo_EventsChange Func UpdateGui($bStart = True) ; Adds events to the main gui ; Check if we have an event to add to the gui If $g_aEvents[0][1] = Null And $bStart = False Then Return ; If we don't have any events ; If the function is called with False, we deletes all controls If $bStart = False Then ; Delete existing controls, so we can recreate them For $i = 1 To UBound($g_aEvents) - 1 GUICtrlDelete($g_idLbl_Event[$i]) ; Delete the Event Name Label GUICtrlDelete($g_idLbl_Days[$i]) ; Deletes the label Days Counter GUICtrlDelete($g_idLbl_Days[$i] + 1) ; Deletes the label Days GUICtrlDelete($g_idLbl_Days[$i] + 2) ; Deletes the label we use as a frame for the gui GUICtrlDelete($g_idLbl_Hrs[$i]) ; Deletes the label Hrs counter GUICtrlDelete($g_idLbl_Hrs[$i] + 1) ; Deletes the label : after hrs GUICtrlDelete($g_idLbl_Min[$i]) ; Deletes the label min counter GUICtrlDelete($g_idLbl_Min[$i] + 1) ; Deletes the label : after min GUICtrlDelete($g_idLbl_Sec[$i]) ; Deletes the label sec counter GUICtrlDelete($g_idLbl_Sec[$i] + 1) ; Deletes the label we use as frame around the time counter GUICtrlDelete($g_idLbl_Sec[$i] + 2) ; Deletes the Group we use as spacer Next EndIf $g_aEvents = DBHandle('GetEvents', $g_iInstance) ; reload the array DBHandle('CloseDB', '') ; Check if there is any events If UBound($g_aEvents) = 1 Then $g_aEvents[0][0] = 1 $g_aEvents[0][1] = Null Return EndIf ; Updates the global GUIHeight $g_iGuiHeight = ($g_iSpace * (UBound($g_aEvents) - 1)) + 8 ; Switch to the CDD gui, else the labels would be created on the last active gui GUISwitch($hCountdownDays) For $i = 1 To UBound($g_aEvents) - 1 ; Adds the events to the Countdown gui $g_idLbl_Event[$i] = GUICtrlCreateLabel($g_aEvents[$i][$eEvent_Name], 8, 14 + (($i - 1) * $g_iSpace), 119, 20, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") GUICtrlSetColor(-1, $g_aColors[$eCol_Name]) ; Navy blue GUICtrlSetTip(-1, SplitText($g_aEvents[$i][$eEvent_Desc], 45), 'Description:', 1, 1) $g_idLbl_Days[$i] = GUICtrlCreateLabel("", 31, 34 + (($i - 1) * $g_iSpace), 32, 20, $SS_RIGHT) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel("Days", 65, 34 + (($i - 1) * $g_iSpace), 34, 20) GUICtrlSetFont(-1, 14, 400, 0, "Arial Narrow") GUICtrlSetColor(-1, $g_aColors[$eCol_DaysLbl]) ; Create a static lable to frame the Time countdown GUICtrlCreateLabel("", 16, 56 + (($i - 1) * $g_iSpace), 102, 26, BitOR($SS_GRAYFRAME, $WS_DISABLED, $SS_SUNKEN)) $g_idLbl_Hrs[$i] = GUICtrlCreateLabel("", 22, 58 + (($i - 1) * $g_iSpace), 18, 20, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 46, 58 + (($i - 1) * $g_iSpace), 8, 20) GUICtrlSetColor(-1, $g_aColors[$eCol_TimeColon]) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Min[$i] = GUICtrlCreateLabel("", 56, 58 + (($i - 1) * $g_iSpace), 18, 20, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 80, 58 + (($i - 1) * $g_iSpace), 8, 20) GUICtrlSetColor(-1, $g_aColors[$eCol_TimeColon]) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Sec[$i] = GUICtrlCreateLabel("", 90, 58 + (($i - 1) * $g_iSpace), 18, 20, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") ; We add a horizontal line as a spacer between the events, but only if we have more that one. But we don't add one after the last If $i >= 1 And $i < UBound($g_aEvents) - 1 And UBound($g_aEvents) - 1 > 1 Then GUICtrlCreateGroup("", 0, 84 + (($i - 1) * $g_iSpace), 135, 9) GUICtrlCreateGroup("", -99, -99, 1, 1) EndIf $g_idLbl_Event[0] = $i Next ; Resizes the Frame label GUICtrlSetPos($idFrame, 0, 0, 136, $g_iGuiHeight + 4) ; Get the position of the Countdown gui Local $aWinPos = WinGetPos($hCountdownDays) ; Updates the height of the Countdown gui, using the pos we got, and the new height using the updated global guiheight _WinAPI_SetWindowPos($hCountdownDays, $HWND_NOTOPMOST, $aWinPos[0], $aWinPos[1], 136, $g_iGuiHeight + 4, _ BitOR($SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOZORDER)) ; Finaly we checks if we have exceeded or maxed out the allowed amounts of Events. ; If so we disables the add event MenuItem, thereby preventing the user to add more events, until ; an Event is either disabled or deleted, making up space for a new one. If UBound($g_aEvents) - 1 >= $g_aSettings[$eSet_Max] Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) EndFunc ;==>UpdateGui Func CbSetState($iCtrlID, $bEnabled) Switch $bEnabled ; Popup checkbox Case True GUICtrlSetState($iCtrlID, $GUI_CHECKED) Case False GUICtrlSetState($iCtrlID, $GUI_UNCHECKED) EndSwitch EndFunc ;==>CbSetState Func Countdown() If $g_aEvents[0][1] = Null Then Return ; If we don't have any events For $i = 1 To UBound($g_aEvents) - 1 ; cycle through events Local $iGetSec = _DateDiff('s', _NowCalc(), StringRegExpReplace($g_aEvents[$i][$eEvent_Date], "(\d{4})-(\d{2})-(\d{2})(.*)", "$1/$2/$3$4")) ; grab seconds of difference from now to future date If $iGetSec <= 0 And StringToType($g_aEvents[$i][$eEvent_Enabled]) = True Then EventHandle($g_aEvents[$i][$eEvent_RowID], $i) EndIf Ticks_To_Time($iGetSec, $g_iDays, $g_iHours, $g_iMins, $g_iSecs) If @error Then ; If time is up, we update days,hours, min and sec. This it to prevent false time/day update of the event, sins TTT uses byref and ; if we don't update the var's the event counter would be equal to the previous event time. $g_iDays = 0 $g_iHours = '00' $g_iMins = '00' $g_iSecs = '00' EndIf ; convert seconds to days/hours/minutes/seconds ; set color and data Switch $g_iDays Case 0 To 5 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 1) ; Red Case 6 To 10 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 2) ; Yellow Case 11 To 15 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 3) ; Green Case Else GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 0) ; Black EndSwitch ; If days = 0 we want to change the timer colors If $g_iDays = 0 Then Switch $g_iHours Case 0 To 6 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 5) ; Red GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 5) ; Red GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 5) ; Red Case 7 To 12 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 6) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 6) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 6) ; Yellow Case 13 To 23 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 7) ; Green GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 7) ; Green GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 7) ; Green EndSwitch Else ; If not we just keep them black GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 4) ; Black GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 4) ; Black GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 4) ; Black EndIf Next EndFunc ;==>Countdown Func EventHandle($iRowID, $iIndex) ; Here we handles the event when it's time is up o_O ConsoleWrite(@CRLF & 'Event Handle' & @CRLF) ; First we disable the event, to prevent it from caling this function more than once. $g_aEvents[$iIndex][$eEvent_Enabled] = False DBHandle('UpdateEventStatus', 'Enabled|False|' & $iRowID) DBHandle('CloseDB', '') ; Set background label of the event to Yellow and text to Red - Indicate that the event is up GUICtrlSetColor($g_idLbl_Event[$iIndex], $g_aColors[$eCol_EventUp]) GUICtrlSetBkColor($g_idLbl_Event[$iIndex], $g_aColors[$eCol_EventUpBk]) ; Check if a sound should be played If StringToType($g_aEvents[$iIndex][$eEvent_SoundPlay]) = True Then SoundPlay($g_aEvents[$iIndex][$eEvent_SoundFile]) ; Check if a popup should be displayed If StringToType($g_aEvents[$iIndex][$eEvent_Pop]) = True Then ; Disable the on event mode, else the GuiGetMsg won't work Opt("GUIOnEventMode", 0) ; Create the popup window Local $iStyle = BitOR($WS_SYSMENU, $WS_POPUP, $DS_SETFOREGROUND, $WS_CAPTION) Local $iExStyle = BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW) Local $hPopup = GUICreate($g_aEvents[$iIndex][$eEvent_Name], 405, 285, Default, Default, $iStyle, $iExStyle) Local $idEdit_Popup = GUICtrlCreateEdit("", 11, 8, 385, 233, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL)) ; Set the Event description test to the edit GUICtrlSetData(-1, @CRLF & SplitText($g_aEvents[$iIndex][$eEvent_Desc]), 45) GUICtrlSetBkColor(-1, $g_aColors[$eCol_GuiBk]) GUICtrlSetFont(-1, 18, 800, 0, "Arial Narrow") ; Boost the font size Local $idBtn_OK = GUICtrlCreateButton("OK", 165, 256, 75, 21, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idBtn_OK SoundPlay('') ; Kill the sound if any GUIDelete($hPopup) ; Delete the gui ExitLoop ; And exit loop EndSwitch WEnd Opt("GUIOnEventMode", 1) ; Reenable OnEventMode EndIf GUICtrlSetOnEvent($g_idLbl_Event[$iIndex], 'Click_Main') EndFunc ;==>EventHandle Func DBHandle($sHandle, ByRef $vData) ConsoleWrite(@CRLF & 'DBHandle call = ' & $sHandle & @CRLF) ; Here we handle all SQLite handles ; Open/Close DataBase, Update/Change Settings, Add/Edit/Delete Events Add/Delete Default Events ; Create a static var to handle open close of the database Local Static $bOpen = True If $bOpen Then $bOpen = False ; Change the static to False, so we don't continues to open the database - when it hasn't been closed Local $g_hDB = _SQLite_Open($g_sDBFile) ; Open the SQLite database If @error Then MsgBox($g_iMBErr, "SQLite Error", "Can't open Database!") Exit -1 EndIf EndIf ; Switch thru the handles Switch $sHandle Case 'ByString' SQLite_QuerryArrayByString($vData) Case 'GetSet' ; Getting settings from the DB Local $aData2D = SQLite_QuerryArray('Settings', $vData) ; Error checker to prevent empty array If UBound($aData2D) = 1 Then Return SetError(-1) EndIf ;Stripping first row, colum 0 and 1 (RowID and Instance) and convert the array to 1D Local $aData1D[0] For $i = 0 To UBound($aData2D, $UBOUND_COLUMNS) - 1 _ArrayAdd($aData1D, StringToType($aData2D[1][$i])) Next ; Return the 1D Settings array Return $aData1D Case 'GetColors' ; Get color settings Local $aData2D = SQLite_QuerryArray('Colors', $vData) If UBound($aData2D) = 1 Then Return SetError(-1) EndIf ;Stripping first row, colum 0 and 1 (RowID and Instance) and convert the array to 1D Local $aData1D[0] For $i = 0 To UBound($aData2D, $UBOUND_COLUMNS) - 1 _ArrayAdd($aData1D, $aData2D[1][$i]) Next ; Return the 1D Settings array Return $aData1D Case 'UpdateSet' ; Updates the settings and colors in the DataBase ; First we creates a 2D array for Settings and Colors Local $aSetCol = StringSplit($g_aSettings[$eSet_RowID] & '|Instance|Max|Remember|SoundPlay|PopUp|Start|Lang|SoundFile|PosLeft|PosTop', '|') Local $aColCol = StringSplit($g_aColors[$eCol_RowID] & '|Instance|GuiBk|DragLbl|Name|DaysCount0|DaysCount1|DaysCount2|DaysCount3|' & _ 'DaysLbl|Time0|Time1|Time2|Time3|TimeColon|EventUp|EventUpBk', '|') Local $aSet[$aSetCol[0]][2], $aCol[$aColCol[0]][2] ; Create Settings 2D array For $i = 0 To $aSetCol[0] - 1 $aSet[$i][0] = $aSetCol[$i + 1] $aSet[$i][1] = $g_aSettings[$i] Next ; Create colors 2D array For $i = 0 To $aColCol[0] - 1 $aCol[$i][0] = $aColCol[$i + 1] $aCol[$i][1] = $g_aColors[$i] Next ; Update the DataBase SQLite_UpdateByArray('Settings', $aSet) SQLite_UpdateByArray('Colors', $aCol) Case 'UpdatePos' ; Update the Position SQLite_UpdateByArray('Settings', $vData) Case 'GetEvents' ; Get all enabled events, for the current instance Return SQLite_QuerryArray('EventsEnabled', $vData) Case 'GetAllEvents' ; Get all events for this instance, enabled and disabled Local $aData = SQLite_QuerryArray('Events', $vData) If UBound($aData) = 1 Then Return SetError(-1) Else Return $aData EndIf Case 'GetSingleEvent' ; Get a single event Local $aData = SQLite_QuerryRow('Events', $vData) If UBound($aData) = 0 Then Return SetError(-1) Else Return $aData EndIf Case 'AddEvent' ; Add an event to the DataBase SQLite_AddByArray('Events', $vData) Case 'DelEvent' ; Delete a single event. SQLite_DelSingle('Events', $vData) Case 'UpdateEvent' ; Update a single event SQLite_UpdateByArray('Events', $vData) Case 'UpdateEventStatus' ; Updates a single coloum Local $aData = StringSplit($vData, '|') SQLite_UpdateSingle('Events', $aData[1], StringToType($aData[2]), $aData[3]) Case 'AddDefEvent' ; Adds a single default event to the DataBase SQLite_AddByArray('DefEvents', $vData) Case 'UpdateDefEvent' ; Updates a singel default event in the DataBase SQLite_UpdateByArray('DefEvents', $vData) Case 'GetDefEvents' ; Get all default evnets from the DataBase Return _ArrayExtract(SQLite_QuerryArray('DefEvents', ''), 1) Case 'GetSingleDefEvent' ; Get a single default event from the DataBase Return SQLite_QuerryRow('DefEvents', $vData) Case 'DelSingleDefEvent' ; Deletes a single Default event from teh DataBase SQLite_DelSingle('DefEvents', $vData) Case 'UpdateSingleSet' ; Updates a single coloum Local $aData = StringSplit($vData, '|') SQLite_UpdateSingle('Settings', $aData[1], StringToType($aData[2]), $g_aSettings[$eSet_RowID]) ContinueCase ; We continues case so the database is closed Case 'CloseDB' ConsoleWrite(@CRLF & 'DataBase was closed' & @CRLF) $bOpen = True ; Set static to True, so when the function is called next time, the datbase is opened _SQLite_Close() ; Close the database Case 'VACUUM' SQLite_Vacuum() EndSwitch EndFunc ;==>DBHandle Func SQLite_QuerryArrayByString($sString) Local $aResult, $iRows, $iColumns, $iRval $iRval = _SQLite_GetTable2D(-1, $sString, $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then Return $aResult EndIf MsgBox(0, 'title', _SQLite_ErrMsg()) EndFunc Func SQLite_UpdateSingle($sTable, $sColum, $vData, $iRowID) ; We update a single columm by using the colum name and the rowid ; First we check if the data we should update is Boolean, we check this course if we try to fastescape ; a boolean value, sqlite gives an error If IsBool($vData) Then $vData = "'" & $vData & "'" Else $vData = _SQLite_FastEscape($vData) ; It's not boolean EndIf ; Update Database _SQLite_Exec(-1, "UPDATE " & $sTable & " SET " & $sColum & " = " & $vData & " WHERE rowid=" & $iRowID & ";") EndFunc ;==>SQLite_UpdateSingle Func SQLite_AddByArray($sTable, $aData) ; Add data to the DataBase using an array For $i = 0 To UBound($aData) - 1 ; Create a string of data to add to the database Local $sData ; First we check if that data it boolean If IsBool($aData[$i]) Then ; The data was boolean, so we update without using fastecsape $sData &= "'" & $aData[$i] & "', " Else $sData &= _SQLite_FastEscape($aData[$i]) & ', ' EndIf Next _SQLite_Exec(-1, "INSERT INTO " & $sTable & " VALUES ( " & StringTrimRight($sData, 2) & ");") EndFunc ;==>SQLite_AddByArray Func SQLite_UpdateByArray($sTable, ByRef $aData) ; Update DataBase using a 2d array, where [0] is column name and [1] is the data to set Local $iRowID = $aData[0][0] For $i = 1 To UBound($aData) - 1 ; First we check if that data it boolean If IsBool($aData[$i][1]) Then ; The data was boolean, so we update without using fastecsape _SQLite_Exec(-1, "UPDATE " & $sTable & " SET " & $aData[$i][0] & " = '" & $aData[$i][1] & "' WHERE rowid=" & $iRowID & ";") Else ; We update using fastescape _SQLite_Exec(-1, "UPDATE " & $sTable & " SET " & $aData[$i][0] & " = " & _SQLite_FastEscape($aData[$i][1]) & " WHERE rowid=" & $iRowID & ";") EndIf Next EndFunc ;==>SQLite_UpdateByArray Func SQLite_DelSingle($sTable, $iRowID) ; Delete a singel row from the table _SQLite_Exec(-1, "DELETE FROM " & $sTable & " WHERE rowid=" & $iRowID & ";") EndFunc ;==>SQLite_DelSingle Func SQLite_DelByInstance($sTable, $iInst) ; Delete a singel row from the table _SQLite_Exec(-1, "DELETE FROM " & $sTable & " WHERE Instance=" & $iInst & ";") EndFunc ;==>SQLite_DelSingle Func SQLite_Vacuum() ; Reset the rowid values, and rebuild the index from the scratch _SQLite_Exec(-1, "VACUUM;") EndFunc ;==>SQLite_Vacuum Func SQLite_QuerryArray($sTable, $iInst) Local $aResult, $iRows, $iColumns, $iRval If $sTable = 'EventsEnabled' Then $iRval = _SQLite_GetTable2D(-1, 'SELECT rowid,* FROM Events WHERE Instance=' & $iInst & " AND Enabled='True';", $aResult, $iRows, $iColumns) ElseIf $sTable = 'DefEvents' Then $iRval = _SQLite_GetTable2D(-1, 'SELECT rowid,* FROM "' & $sTable & '";', $aResult, $iRows, $iColumns) Else $iRval = _SQLite_GetTable2D(-1, 'SELECT rowid,* FROM "' & $sTable & '" WHERE Instance=' & $iInst & ';', $aResult, $iRows, $iColumns) EndIf If $iRval = $SQLITE_OK Then Return $aResult EndIf MsgBox(0, 'title', _SQLite_ErrMsg()) EndFunc ;==>SQLite_QuerryArray Func SQLite_QuerryRow($sTable, $iRowID) Local $aRow _SQLite_QuerySingleRow(-1, "SELECT * FROM " & $sTable & " WHERE rowid=" & $iRowID & ";", $aRow) ; Select single row Return $aRow EndFunc ;==>SQLite_QuerryRow Func SQLite_QuerrySingle($sTable, $sColum, $iRowID) Local $aRow _SQLite_QuerySingleRow(-1, "SELECT " & $sColum & " FROM " & $sTable & " WHERE rowid=" & $iRowID & ";", $aRow) ; Select single field ! Return $aRow EndFunc ;==>SQLite_QuerrySingle Func CreateDB() ; Create DataBase Local $sTables $sTables &= 'CREATE TABLE [Colors](' $sTables &= '[Instance] INT,' $sTables &= '[GuiBk] VARCHAR,' $sTables &= '[DragLbl] VARCHAR,' $sTables &= '[Name] VARCHAR,' $sTables &= '[DaysCount0] VARCHAR,' $sTables &= '[DaysCount1] VARCHAR,' $sTables &= '[DaysCount2] VARCHAR,' $sTables &= '[DaysCount3] VARCHAR,' $sTables &= '[DaysLbl] VARCHAR,' $sTables &= '[Time0] VARCHAR,' $sTables &= '[Time1] VARCHAR,' $sTables &= '[Time2] VARCHAR,' $sTables &= '[Time3] VARCHAR,' $sTables &= '[TimeColon] VARCHAR,' $sTables &= '[EventUp] VARCHAR,' $sTables &= '[EventUpBk] VARCHAR);' $sTables &= 'CREATE TABLE[Events](' $sTables &= '[Instance] INT,' $sTables &= '[Name] VARCHAR,' $sTables &= '[Desc] VARCHAR,' $sTables &= '[EndDate] DATETIME,' $sTables &= '[SoundFile] VARCHAR,' $sTables &= '[PlaySound] BOOLEAN,' $sTables &= '[PopUp] BOOLEAN,' $sTables &= '[Enabled] BOOLEAN);' $sTables &= 'CREATE TABLE[Position](' $sTables &= '[Instance] INT,' $sTables &= '[PosLeft] INT,' $sTables &= '[PosTop] INT,' $sTables &= '[Pin] BOOLEAN);' $sTables &= 'CREATE TABLE[DefEvents](' $sTables &= '[Name] VARCHAR UNIQUE ON CONFLICT REPLACE,' $sTables &= '[Desc] VARCHAR,' $sTables &= '[Days] INT,' $sTables &= '[SoundFile] VARCHAR,' $sTables &= '[PlaySound] BOOLEAN,' $sTables &= '[PopUp] BOOLEAN);' ; Insert default data Local $sDefData $sDefData &= "INSERT INTO Position VALUES ('0', -1, -1, 'False');" $sDefData &= "INSERT INTO Colors VALUES ('0', '0x4E4E4E','0x808080','0xFFFFFF', '0x000000', '0xFF0000', " & _ "'0xFFFF00', '0x008000', '0x000000', '0x000000','0xFF0000', '0xFFFF00', '0x008000', '0x000000', '0xFF0000', '0xFFFF00');" _SQLite_Open(@ScriptDir & '\Data.db') ; Create the DataBase If @error Then Return SetError(-1) EndIf _SQLite_Exec(-1, $sTables) If @error Then Return SetError(-1) EndIf _SQLite_Exec(-1, $sDefData) If @error Then Return SetError(-1) EndIf _SQLite_Close() If @error Then Return SetError(-1) EndIf EndFunc ;==>CreateDB Func Ticks_To_Time($iSeconds, ByRef $idays, ByRef $iHours, ByRef $iMins, ByRef $iSecs) ; second conversion. ; modified: added days. added format style, to use 00 for time If Number($iSeconds) > 0 Then $idays = Int($iSeconds / 86400) $iSeconds = Mod($iSeconds, 86400) $iHours = StringFormat("%02d", Int($iSeconds / 3600)) $iSeconds = Mod($iSeconds, 3600) $iMins = StringFormat("%02d", Int($iSeconds / 60)) $iSecs = StringFormat("%02d", Mod($iSeconds, 60)) Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>Ticks_To_Time Func GUICtrlSetDataAndColor($hWnd, $iCount, $iColor) ; Set Day(s), Hour(s), Min(s), Sec(s) and color to the countdown labels Local $dColor Switch $iColor ; Check if we chould use a color Case 0 ; Black <- Default color $dColor = $g_aColors[$eCol_Days0] Case 1 ; Red $dColor = $g_aColors[$eCol_Days1] Case 2 ; Yellow $dColor = $g_aColors[$eCol_Days2] Case 3 ; Green $dColor = $g_aColors[$eCol_Days3] Case 4 $dColor = $g_aColors[$eCol_Time0] Case 5 $dColor = $g_aColors[$eCol_Time1] Case 6 $dColor = $g_aColors[$eCol_Time2] Case 7 $dColor = $g_aColors[$eCol_Time3] EndSwitch If GUICtrlRead($hWnd) <> $iCount Or GUICtrlRead($hWnd) = '' Then ; if data is different then change. helps with flickering GUICtrlSetData($hWnd, $iCount) GUICtrlSetColor($hWnd, $dColor) EndIf EndFunc ;==>GUICtrlSetDataAndColor Func CalcEndDate($idays, $sTime) ; Calculates a new date by adding a specified number of Days to an initial date Return _DateAdd('D', $idays, @YEAR & '/' & @MON & '/' & @MDAY & ' ' & $sTime) EndFunc ;==>CalcEndDate Func StringToType(ByRef $vData) ; Converts a string to bool, Number or KeyWord Local $aData = StringRegExp($vData, "(?i)\bTrue\b|\bFalse\b|\bNull\b|\bDefault\b", 3) If Not IsArray($aData) Then Return $vData Switch $aData[0] Case 'True' Return True Case 'False' Return False Case 'Null' Return Null Case 'Default' Return Default Case Else Return Int($aData[0]) EndSwitch EndFunc ;==>StringToType Func SplitText($sString, $iLenght = 45) #cs This splits a large text up into cunks at N lengt, at the last space within the nLength specified, and seperated with a @CRLF eg. 'A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." Would be formated as this: A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." #ce Local $sResult = StringRegExpReplace($sString, ".{1," & $iLenght - 1 & "}\K(\s{1,2}|$)", @CRLF) Return $sResult EndFunc ;==>SplitText Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView_EditEvent, $tInfo, $iRowID, $aData $hWndListView_EditEvent = GUICtrlGetHandle($idEditEvent + 2) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView_EditEvent Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ; Get index of selected Event, and call the listview handle GUICtrlSendToDummy($idEditEvent, DllStructGetData($tInfo, "Index")) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Other suggestions, on how to make my code more effective, is also welcome Cheers /Rex
  14. Another way to this is to embed the resource icon/image as Base64 code directly in the script code, and using this from @UEZ I use these functions (I not 100%, but quit sure I got them from @UEZ also) to add images to either button or to a pic control. ; Set gui button images using Base64 and memwrite Func SetBtnImg($hButton, $dString) Local $Bmp_Button = _GDIPlus_BitmapCreateFromMemory($dString, True) _WinAPI_DeleteObject(_SendMessage($hButton, $BM_SETIMAGE, $IMAGE_BITMAP, $Bmp_Button)) _WinAPI_UpdateWindow($hButton) _WinAPI_DeleteObject($Bmp_Button) EndFunc ;==>SetBtnImg ;Set gui images using Base64 and memwrite Func SetImg($idImg, $dString) Local $hBmp = _GDIPlus_BitmapCreateFromMemory($dString, True) ;to load an image from the net Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idImg, $STM_SETIMAGE, $IMAGE_BITMAP, $hBmp)) EndFunc ;==>SetImg Only drawback is if the images is updated, then you need to regenerate the Base64 code Cheers /Rex
  15. I ended up using buttons, not as slick and pretty - but it allowed me to get on with my project, after using ½ a day to try to figure out a way to not use buttons 😕 I even tried using ListBox, but LB don't handle on event - and though I could capture the focus and even a mouse click at the LB, the capture enter key failed most of the time. Cheers /Rex
  16. Hi I'm trying to catch when a label that has $WS_TABSTOP, is "hit" when the user uses the tab button to move between controls I'w been looking at wm_command and $EN_SETFOCUS, but that only works when the user clicks the label. I have this GUI ; -- Created with ISN Form Studio 2 for ISN AutoIt Studio -- ; #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiButton.au3> Global Const $hColors = GUICreate("Colors",292,282,-1,-1,BitOr($WS_POPUP, $WS_CAPTION, $WS_SYSMENU),-1) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close", $hColors) GUICtrlCreateLabel("Change label colors:",8,10,100,15,-1,-1) GUICtrlSetBkColor(-1,"-2") Global Const $idColor = GUICtrlCreateDummy() GUICtrlCreateLabel("GUI BkGround:",8,36,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("",100,36,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x4E4E4E") GUICtrlCreateLabel("GUI Drag label:",8,60,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("",100,60,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x808080") GUICtrlCreateLabel("Event name:",8,84,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlCreateLabel("",100,84,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFFFFFF") GUICtrlCreateLabel("Days default:",8,108,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When < 16 days left") GUICtrlCreateLabel("",100,108,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("Days 0 to 5:",8,132,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When there is 0 to 5 days left") GUICtrlCreateLabel("",100,132,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFF0000") GUICtrlCreateLabel("Days 6 to 10:",8,156,80,15,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When there is 6 to 10 days left") GUICtrlCreateLabel("",100,156,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFFFF00") GUICtrlCreateLabel("Days 11 To 15:",8,180,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When there is 11 to 15 days left") GUICtrlCreateLabel("",100,180,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x008000") GUICtrlCreateLabel("Days label:",8,204,80,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"This is the fixed label Days") GUICtrlCreateLabel("",100,204,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("Time Default:",142,36,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When <0 days left") GUICtrlCreateLabel("",261,36,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("Time 0 to 6:",142,60,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When days = 0 and between 0 to 6 hours left") GUICtrlCreateLabel("",261,60,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFF0000") GUICtrlCreateLabel("Time 7 to 12",142,84,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When days left = 0 and between 7 to 12 hours left") GUICtrlCreateLabel("",261,84,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFFFF00") GUICtrlCreateLabel("Time 13 to 23:",142,108,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"When days = 0 and between 13 to 23 hours left.") GUICtrlCreateLabel("",261,108,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x008000") GUICtrlCreateLabel("Time colon:",142,132,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"The ':' between hour, min and sec") GUICtrlCreateLabel("",261,132,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("Event up:",142,156,100,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"Colour of the event name, when time is up") GUICtrlCreateLabel("",261,156,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFF0000") GUICtrlCreateLabel("Event up BkGround:",142,180,110,20,$SS_CENTERIMAGE,-1) GUICtrlSetBkColor(-1,"-2") GUICtrlSetTip(-1,"Background colour of the Event name, when time is up") GUICtrlCreateLabel("",261,180,20,20,BitOr($WS_TABSTOP, $SS_SUNKEN),-1) GUICtrlSetOnEvent(-1,"ColorPic") GUICtrlSetBkColor(-1,"0xFFFF00") Global Const $idBtn_ColorSave = GUICtrlCreateButton("Save",8,256,75,20,-1,-1) GUICtrlSetTip(-1,"Saves and closes") GUICtrlCreateButton("Close",210,256,75,20,-1,-1) GUICtrlSetOnEvent(-1,"hWnd_Close") GUICtrlSetTip(-1,"Closes with out saving") What I'm trying to do is when tab over the 20x20 color label, to set some state to show the user that the label has focus, just like when using tab on buttons My first thought was to use buttons, but a colored button looks ugly with the 3d rounded edges, and $BS_FLAT don't work (I have read that one could use some dll kill utx theme trick) My second idea was to create buttons with images, but then I have to find a way to change the image color when the user changes the color. Cheers /Rex
  17. You need to tell Mouse click which button to use: MouseClick ( "button" [, x, y [, clicks = 1 [, speed = 10]]] ) From the help file #include <AutoItConstants.au3> ; Double click at the current mouse position. MouseClick($MOUSE_CLICK_LEFT) MouseClick($MOUSE_CLICK_LEFT) ; Double click at the x, y position of 0, 500. MouseClick($MOUSE_CLICK_LEFT, 0, 500, 2) ; Double click at the x, y position of 0, 500. This is a better approach as it takes into account left/right handed users. MouseClick($MOUSE_CLICK_PRIMARY, 0, 500, 2) So this should do the trick #include <AutoItConstants.au3> $x1 = InputBox("xx", "xxxx?") if ($x1 = 1) Then MouseClick($MOUSE_CLICK_LEFT,132,393,1) Sleep(5000) EndIf Cheers /Rex
  18. Maybe this one can help you along the way Cheers /Rex
  19. Darn. I did a search in this thread, and even read thru all 14 pages to be sure that it wasn't reported, but I never thought about doing a general forum search Thx Melba, you don't have anything to be sorry about, your udf works swell in all my other programs. Ill look at the thread - but for now I just dropped the onhover function, was only using it one place - and that can be replaced with the nativ set tip Cheers /Rex
  20. Hi Melba I broke your UDF If I use Your UDF and the GUICtrlOnHover UDF in the same script, I get the above result Sample code to replicate the problem (at least on my win10 and my test win7) #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=TEST_GUI_ERROR.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <includes\GUICtrlOnHover.au3> #include "Includes\ExtMsgBox.au3" Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 221, 48, Default, Default) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $idInp_1 = GUICtrlCreateInput("This is a text that, is longer than 34 chars in len, and therefore it should be displayed in a tooltip, upon hover", 8, 8, 153, 21) _GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Hover_Func") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() Local $iMsgAnsw = _ExtMsgBox($EMB_ICONQUERY, $MB_YESNO, "Close GUI", "Do you want to close the GUI?") ; Run thru the answers Switch $iMsgAnsw Case 1 ; The user clicked yes ; Delete the gui's GUIDelete($Form1) Exit ; And we exit the program Case 2 ; The user clicked no Return ; We return doing nothing EndSwitch EndFunc Func _Hover_Func($iCtrlID, $iParam) Switch $iParam Case 1 Local $sdata = GUICtrlRead($idInp_1) If $sdata <> '' And StringLen($sdata) > 34 Then If Not IsDeclared("sToolTipAnswer") Then Local $sToolTipAnswer $sToolTipAnswer = ToolTip(GUICtrlRead($idInp_1), Default, Default, "", 1, 1) EndIf Case 2 ToolTip("") EndSwitch EndFunc ;==>_Hover_Func Cheers /Rex
  21. Fixed some minor bugs, if day was 0 and time was 7 to 23 the counter wasn't shown.
  22. I needed a program that could count down to xx days. I found lots of count downer's, but common for them all was that I needed to know the end date, but what I needed was one where I could just add the amount of days. So I ended up creating my own count down, that could do just that. Now I would like to share what I ended up with. I did borrow some of the count down code from this nice count down Stylish Countdown GUI by @billthecreator So what can this countdown do? 1. Countdown to a specific day, that can be chosen either by the amount of days to count down to, or by choosing a date. 2. Edit an existing event. 3. Delete an existing event. 4. On mouse over the Event, the event description is shown as a tip. 5. Play a sound when time is up (if enabled for the event). 6. Show a popup when time is up (if enabled for the event), the popup text is the event description. 7. Save an event as default, so it can be reused. 8. Can be pinned in place, so the gui is unmovable. 9. Can remember the last GUI position (If chosen in the settings) 10. Uses colors on days / time, Black, Green, Yellow and Red. When Less than 5 days to event, the days will turn Red, 6 to 10 days Yellow, 11+ Green The time will change to Green when 0 days and 23 to 13 hours left, Yellow when 12 to 7 hours and Red from 5 to 0, else it's Black When the time is up, the Event name label background will change to Yellow and the text to Red When adding/Editing/Deleting an event the GUI is updated, not by restarting the program, but by deleting and recreating the events. When an event time is up, the event is set as disabled - but will still exist in the event ini file, but it won't be loaded into the GUI when the countdown'er is started. The event can be edited, and restarted or deleted permanently. Some screenshots: #include <Date.au3> #include <ColorConstants.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <String.au3> #include <GuiComboBox.au3> #include <MsgBoxConstants.au3> #include <WinAPIDlg.au3> #include <Sound.au3> #include <GuiListBox.au3> #include <WinAPISysWin.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Opt('GUIResizeMode', $GUI_DOCKALL) ; To prevent ctrls to move when we add a new event OnAutoItExitRegister('MenuItem_ExitClick') ; To save pos at closedown, if savepos is enabled Global $g_iSecs, $g_iMins, $g_iHours, $g_iDays ; Get settings Global $g_sSetFile = @ScriptDir & '\Settings.ini' Global $g_sEventFile = @ScriptDir & '\Events.ini' Global $g_iMaxEvents = IniRead($g_sSetFile, 'Settings', 'MaxEvents', 6) ; Max Number of events Global $g_bPin = StringToType(IniRead($g_sSetFile, 'Settings', 'Pin', False)) ; Pin in place, GUI Can't be moved Global $g_bRemember = StringToType(IniRead($g_sSetFile, 'Settings', 'Remember', False)) ; Remember last position and start at that pos Global $g_iGuiLeft = IniRead($g_sSetFile, 'settings', 'posx', -1) ; Gui Left pos (x) Global $g_iGuiRight = IniRead($g_sSetFile, 'settings', 'posy', -1) ; Gui right pos (y) Global $g_sSoundFile = IniRead($g_sSetFile, 'Settings', 'SoundFile', @WindowsDir & '\media\tada.wav') Global $g_bSoundPlay = StringToType(IniRead($g_sSetFile, 'Settings', 'SoundPlay', True)) Global $g_bPopup = StringToType(IniRead($g_sSetFile, 'Settings', 'popup', True)) ; Do a popup window with event description Global $g_bStartWithWin = StringToType(IniRead($g_sSetFile, 'Settings', 'StartWithWin', True)) ; If the prog should start with windows ; Check if the gui should start at last saved position If $g_bRemember = False Then $g_iGuiRight = -1 ; Default Screen center $g_iGuiLeft = -1 ; Default Screen center EndIf ; Creates an array to hold the end dates of the event(s), it's State (Enabled) and the SectionName of the event. ; this array we uses to calc the countdown, and to prevent the need to keep reopen the event ini file, to get the ; enddate of a given event. Global $g_aEventData[1][3] = [['EndDate', 'Enabled', 'SectionName']] ; Get events Global $g_aEvents = IniReadSectionNames($g_sEventFile) ; Check if we have any Events If Not IsArray($g_aEvents) Then ; If we don't have any events, we creates the array with 1 and Null, 1 to be used to create an empty gui ; Null so we know that there isn't any events Global $g_aEvents[2] = [1, Null] EndIf ; call the EventOnLoad function EventOnLoad() Global $g_idLbl_Days[$g_iMaxEvents + 1], _ $g_idLbl_Hrs[$g_iMaxEvents + 1], _ $g_idLbl_Min[$g_iMaxEvents + 1], _ $g_idLbl_Sec[$g_iMaxEvents + 1], _ $g_idLbl_Event[$g_iMaxEvents + 1] Global $g_iSpace = 80 Global $g_iGuiHeight = ($g_iSpace * $g_aEvents[0]) + 8 #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hCountdownDays.kxf Global $hCountdownDays = GUICreate("CountDown Days", 136, $g_iGuiHeight, $g_iGuiLeft, $g_iGuiRight, $WS_POPUP, $WS_EX_TOOLWINDOW) ; Gui menu Global $hCountdownDayscontext = GUICtrlCreateContextMenu() Global $MenuItem_EventHandling = GUICtrlCreateMenu("Event(s)", $hCountdownDayscontext) Global $MenuItem_AddEvent = GUICtrlCreateMenuItem("Add", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_AddEventClick") Global $MenuItem_EditEvent = GUICtrlCreateMenuItem("Edit", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_EditEventClick") Global $MenuItem_DeleteEvent = GUICtrlCreateMenuItem("Delete", $MenuItem_EventHandling) GUICtrlSetOnEvent(-1, "MenuItem_DeleteEventClick") Global $MenuItem_Settings = GUICtrlCreateMenuItem("Settings", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_SettingsClick") Global $MenuItem_Pin = GUICtrlCreateMenuItem("Pin in Place", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_PinClick") Global $MenuItem_Exit = GUICtrlCreateMenuItem("Exit", $hCountdownDayscontext) GUICtrlSetOnEvent(-1, "MenuItem_ExitClick") GUISetBkColor(0x4E4E4E) Global $idLbl_Move = GUICtrlCreateLabel("", 1, 1, 134, 12, $SS_CENTER, $GUI_WS_EX_PARENTDRAG) GUICtrlSetFont(-1, 6, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0x808080) ; Create a label to frame the gui, so it don't look to flat Global $idFrame = GUICtrlCreateLabel('', 0, 0, 136, $g_iGuiHeight, BitOR($SS_SUNKEN, $WS_DISABLED, $SS_SIMPLE)) If $g_aEvents[1] = Null Then UpdateGui(False) ; Update Countdown GUI Else UpdateGui(True) ; Update Countdown GUI EndIf ; check if we needs to tick the pin, and disable the Move label If $g_bPin = True Then GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) GUICtrlSetState($idLbl_Move, $GUI_DISABLE) EndIf ; Check if we should disable the add event MenuItem If $g_aEvents[0] >= $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hAddEvent.kxf Global $hAddEvent = GUICreate("Add Event", 206, 407, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idAddEvent = GUICtrlCreateDummy() ; Create a dumme, we use this to calculate the CtrlID of the Controls created after the dummy GUICtrlCreateLabel("Default Events:", 8, 8, 77, 17) ; This would be dummy + 1 in ID GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetTip(-1, "Saved default events") GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 17) GUICtrlCreateInput("", 8, 72, 185, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event." & @CRLF & "This is the text that will be shown at the gui." & @CRLF _ & "Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 104, 89, 17) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description." & @CRLF _ & "This wil be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlCreateCheckbox("Choose Event date by calendar", 8, 216, 170, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlCreateLabel("Days to event:", 8, 240, 73, 17) GUICtrlCreateInput("", 8, 256, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event") GUICtrlCreateLabel("Time of event", 112, 240, 69, 17) GUICtrlCreateDate('', 112, 256, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') ; Set time style GUICtrlCreateLabel("Event date:", 8, 240, 59, 17) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateDate('', 8, 256, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') ; Set Date and Time style GUICtrlSetTip(-1, "The end date of the event") GUICtrlSetState(-1, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Diasbled and hidden yy default GUICtrlCreateLabel("Sound to play:", 8, 280, 72, 17) GUICtrlCreateInput('', 8, 296, 160, 21, $ES_READONLY) ; Default sound to play at event end GUICtrlCreateButton("...", 174, 296, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 8, 328, 73, 17) GUICtrlCreateCheckbox("Popup", 88, 328, 49, 17) GUICtrlCreateCheckbox("Save as default event", 8, 352, 124, 17) GUICtrlSetTip(-1, "Saves the event as a default event, that later can be choosen from the dropdown") GUICtrlCreateButton("&Add event", 8, 376, 75, 21) GUICtrlSetTip(-1, "Adds the events and closes the add event gui") GUICtrlSetOnEvent(-1, "idBtn_AddEventClick") GUICtrlCreateButton("&Close", 120, 376, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf Global $hEditEvent = GUICreate("Edit Event", 206, 407, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idEditEvent = GUICtrlCreateDummy() GUICtrlCreateLabel("Choose events to edit:", 8, 8, 110, 17) GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 17) GUICtrlCreateInput("", 8, 72, 185, 21) GUICtrlSetLimit(-1, 24) GUICtrlSetTip(-1, "Name of event. This is the text that will be shown at the gui. Max length is 24 chars") GUICtrlCreateLabel("Event description:", 8, 104, 89, 17) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL)) GUICtrlSetTip(-1, "Event description. This will be shown as a tip upon hovering, and also in the popup (if popup is enabled)") GUICtrlCreateCheckbox("Choose event date by calender", 8, 216, 170, 17) GUICtrlSetOnEvent(-1, "idCb_ChoseDateClick") GUICtrlCreateLabel("Days to event:", 8, 240, 73, 17) GUICtrlCreateInput("", 8, 256, 73, 21, BitOR($ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 3) GUICtrlSetTip(-1, "Days to the event, time will be from the time the event is added") GUICtrlCreateLabel("Time of event", 112, 240, 69, 17) GUICtrlCreateDate('', 112, 256, 82, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT)) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'HH:mm:ss') GUICtrlSetTip(-1, "Time of the event") GUICtrlCreateLabel("Event date:", 8, 240, 59, 17) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateDate('', 8, 256, 186, 21, 0) GUICtrlSendMsg(-1, $DTM_SETFORMATW, 0, 'yyyy/MM/dd HH:mm:ss') GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetTip(-1, "Choose the end date of the event") GUICtrlCreateLabel("Sound to play:", 8, 280, 72, 17) GUICtrlCreateInput("", 8, 296, 160, 21, $ES_READONLY) GUICtrlCreateButton("...", 174, 296, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateCheckbox("Play sound", 8, 328, 73, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateCheckbox("Popup", 88, 328, 49, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateCheckbox("Enabled", 8, 352, 60, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetTip(-1, "Enables or disables the event, if disabled it don't show in the countdown gui") GUICtrlCreateButton("&Update", 8, 376, 75, 21) GUICtrlSetTip(-1, "Updates the selected event") GUICtrlSetOnEvent(-1, "idBtn_UpdateEventClick") GUICtrlCreateButton("&Close", 120, 376, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hEditEvent.kxf Global $hDeleteEvent = GUICreate("Delete Event", 206, 318, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") Global $idDelEvent = GUICtrlCreateDummy() GUICtrlCreateLabel("Choose event to delete:", 8, 8, 122, 16) GUICtrlCreateCombo("", 8, 24, 185, 25, $CBS_DROPDOWNLIST) GUICtrlSetTip(-1, "Event to delete") GUICtrlSetOnEvent(-1, "idCombo_EventsChange") GUICtrlCreateLabel("Event Name:", 8, 56, 66, 16) GUICtrlCreateInput("", 8, 72, 185, 21, $ES_READONLY) GUICtrlCreateLabel("Event description:", 8, 104, 89, 16) GUICtrlCreateEdit("", 8, 120, 185, 89, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_READONLY)) GUICtrlCreateLabel("Event date:", 8, 216, 59, 17) GUICtrlCreateInput("", 8, 232, 186, 21, $ES_READONLY) GUICtrlCreateCheckbox("Enabled", 8, 264, 60, 17) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateButton("&Delete", 8, 288, 75, 21) GUICtrlSetTip(-1, "Deletes selected event") GUICtrlSetOnEvent(-1, "idBtn_EventDeleteClick") GUICtrlCreateButton("&Close", 120, 288, 75, 21) GUICtrlSetTip(-1, "Closes the add event, without saving the event.") GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form=D:\Profil\Rex\ISN AutoIt Studio\Projects\Countdown Days\GUI\hSettings.kxf Global $hSettings = GUICreate("Settings", 203, 327, Default, Default, BitOR($WS_SYSMENU, $WS_POPUP, $WS_CAPTION)) GUISetOnEvent($GUI_EVENT_CLOSE, "hWnd_Close") GUICtrlCreateLabel("Max Number of events:", 8, 12, 114, 17) GUICtrlSetTip(-1, "Max number of events." & @CRLF & "On a 1920x1080 Screen the max would be aprox 13 events.") Global $idInp_Sett_MaxEvents = GUICtrlCreateInput("", 122, 8, 21, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) Global $idCb_Sett_Remember = GUICtrlCreateCheckbox("Remember last position.", 8, 32, 130, 17) GUICtrlSetTip(-1, "When countdown is closed, it saves the position it was placed, and starts at that position.") Global $idCb_Sett_PlaySound = GUICtrlCreateCheckbox("Play Sound", 8, 56, 74, 17) GUICtrlSetTip(-1, "Plays a sound when the event time is up.") Global $idCb_Sett_Pop = GUICtrlCreateCheckbox("Show popup", 88, 56, 80, 17) GUICtrlSetTip(-1, "Shows a popup windows, when the event time is up." & @CRLF & "The content of the popup windows will be the event description.") Global $idInp_Sett_Sound = GUICtrlCreateInput("", 8, 104, 153, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY)) GUICtrlSetTip(-1, "Default sound to play when the event time is up.") Global $idCb_Sett_StartWithWin = GUICtrlCreateCheckbox("Start with windows", 8, 80, 110, 17) GUICtrlSetTip(-1, "Start the program with windows") Global $idBtn_Sett_SoundBrowse = GUICtrlCreateButton("...", 168, 104, 21, 21) GUICtrlSetOnEvent(-1, "idBtn_SoundBrowseClick") GUICtrlCreateLabel("Default events:", 8, 136, 76, 17) Global $idList_Sett_DefEvents = GUICtrlCreateList("", 8, 152, 185, 97) GUICtrlSetTip(-1, "Default events that, can be picked from add event.") GUICtrlCreateButton("&Remove", 8, 256, 75, 21) GUICtrlSetTip(-1, "Deletes the selected Default event") GUICtrlSetOnEvent(-1, "idBtn_Sett_RemEventClick") GUICtrlCreateButton("&OK", 8, 296, 75, 21) GUICtrlSetOnEvent(-1, "idBtn_Sett_OKClick") GUICtrlCreateButton("&Close", 120, 296, 75, 21) GUICtrlSetOnEvent(-1, "hWnd_Close") GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### ;~ If $cmdline[0] = 1 Then RelHandle($cmdline[1]) Countdown() AdlibRegister("Countdown", 1000) While 1 Sleep(100) WEnd Func EventOnLoad($bMsg = True) ; This function is used to prevent array subscript dimension range exceeded, and to remove events that is currently disabled. ; Also it checks if there is more events enabled that max events allows, and throws a msg about it - and trims the max events ; to match the MaxEvents allowed ; First we removes the events that is currently disabled Local $sDelRange ; To save the array index where the disabled event is stored For $i = 1 To $g_aEvents[0] ; Check if the event is disabled, using StringToType to convert string to Bool If StringToType(IniRead($g_sEventFile, $g_aEvents[$i], 'Enabled', True)) = False Then ; If the event is disabled we add the index to our save index var and adds a ";" in case that more than one is disabled $sDelRange &= $i & ';' EndIf Next If $sDelRange <> '' Then ; If we had some Disabled events, we remove them from the array _ArrayDelete($g_aEvents, StringTrimRight($sDelRange, 1)) ; And then we update the value of $g_aEvents[0] $g_aEvents[0] = UBound($g_aEvents) - 1 If $g_aEvents[0] = 0 Then ; If there is no enabled events Dim $g_aEvents[2] = [1, Null] ; We updates the array, so we know that there is't any enabled events EndIf EndIf ; Then we check if there is more events that allowed If $g_aEvents[0] > $g_iMaxEvents And $bMsg = True Then ; If there is more events that allowed, we throw a warn - and trims the array to max MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Error', _ 'The amount of events exceeds the max nr of events' & @CRLF & _ 'Only the first ' & $g_iMaxEvents & ' events will be loaded!') $g_aEvents[0] = $g_iMaxEvents EndIf ; Updates the EventData array ReDim $g_aEventData[UBound($g_aEvents)][3] ; Add enddate to the array For $i = 1 To $g_aEvents[0] $g_aEventData[$i][0] = IniRead($g_sEventFile, $g_aEvents[$i], 'EndDate', _NowCalc()) $g_aEventData[$i][1] = StringToType(IniRead($g_sEventFile, $g_aEvents[$i], 'Enabled', True)) $g_aEventData[$i][2] = $g_aEvents[$i] Next EndFunc ;==>EventOnLoad Func MenuItem_AddEventClick() ; Add default evnets to dropdown Local $aDefEvents = IniReadSectionNames($g_sSetFile) If IsArray($aDefEvents) Then For $i = 1 To $aDefEvents[0] If $aDefEvents[$i] <> 'Settings' Then ; If the name is settings we ignore it ; Add the defaults to the combo and revert the name from hex to string. GUICtrlSetData($idAddEvent + 2, _HexToString($aDefEvents[$i])) EndIf Next EndIf ; Set default sound to play GUICtrlSetData($idAddEvent + 15, $g_sSoundFile) GUICtrlSetTip($idAddEvent + 15, $g_sSoundFile) ; Check if the playsound and popup is enabled in settings CbSetState($idAddEvent + 17, $g_bSoundPlay) CbSetState($idAddEvent + 18, $g_bPopup) ; Set focus to the Event Name input GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) ; Show the gui GUISetState(@SW_SHOW, $hAddEvent) EndFunc ;==>MenuItem_AddEventClick Func MenuItem_DeleteEventClick() Local $aEvents = IniReadSectionNames($g_sEventFile) If IsArray($aEvents) Then For $i = 1 To $aEvents[0] GUICtrlSetData($idDelEvent + 2, IniRead($g_sEventFile, $aEvents[$i], 'Name', 'Error Reading Name')) Next EndIf GUISetState(@SW_SHOW, $hDeleteEvent) EndFunc ;==>MenuItem_DeleteEventClick Func MenuItem_EditEventClick() ; First we get events from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) If IsArray($aEvents) Then For $i = 1 To $aEvents[0] GUICtrlSetData($idEditEvent + 2, IniRead($g_sEventFile, $aEvents[$i], 'Name', 'Error Reading Name')) Next EndIf ; Then we ticks of the date checkbox so it shows date picker GUICtrlSetState($idEditEvent + 7, $GUI_CHECKED) ; And hides/disables the Days to evnet / event time input and labels GUICtrlSetState($idEditEvent + 8, $GUI_HIDE) ; Hide the label Days to event GUICtrlSetState($idEditEvent + 9, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the input Days to event GUICtrlSetData($idEditEvent + 9, '') ; Clear the input Days to event GUICtrlSetState($idEditEvent + 10, $GUI_HIDE) ; Hides the label Time to event GUICtrlSetState($idEditEvent + 11, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the TimePicker Time to event ; Show date picker and lable GUICtrlSetState($idEditEvent + 12, $GUI_SHOW) ; Show the label Event date GUICtrlSetState($idEditEvent + 13, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the Date time picker ; Then we show the GUI GUISetState(@SW_SHOW, $hEditEvent) EndFunc ;==>MenuItem_EditEventClick Func MenuItem_SettingsClick() ; Update the gui with info's from the settings file, or if no settings file exists, with defaults ; Add default evnets to Listbox (The events that is saved, and can be loaded in add event) Local $aDefEvents = IniReadSectionNames($g_sSetFile) If IsArray($aDefEvents) Then ; If it's an array we continue For $i = 1 To $aDefEvents[0] If $aDefEvents[$i] <> 'Settings' Then ; If the name is settings we ignore it ; Add the defaults to the listbox and convert the name from hex to string. _GUICtrlListBox_AddString($idList_Sett_DefEvents, _HexToString($aDefEvents[$i])) EndIf Next EndIf ; Check if the Remember, playsound, popup and Start with windows is enabled in settings CbSetState($idCb_Sett_Remember, $g_bRemember) CbSetState($idCb_Sett_PlaySound, $g_bSoundPlay) CbSetState($idCb_Sett_Pop, $g_bPopup) CbSetState($idCb_Sett_StartWithWin, $g_bStartWithWin) ; Set default sound GUICtrlSetData($idInp_Sett_Sound, IniRead($g_sSetFile, 'Settings', 'SoundFile', @WindowsDir & '\media\Tada.wav')) ; Set max events GUICtrlSetData($idInp_Sett_MaxEvents, IniRead($g_sSetFile, 'Settings', 'MaxEvents', 6)) ; Show the gui GUISetState(@SW_SHOW, $hSettings) EndFunc ;==>MenuItem_SettingsClick Func MenuItem_ExitClick() ; Check if the program should save it's poition If $g_bRemember = True Then PosSave() Exit EndFunc ;==>MenuItem_ExitClick Func MenuItem_PinClick() ; Get state of MenuItem Pin in place ; If the pin is enabled, the gui can't be moved If BitAND(GUICtrlRead($MenuItem_Pin), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($MenuItem_Pin, $GUI_UNCHECKED) $g_bPin = False ; Update the var IniWrite($g_sSetFile, 'Settings', 'Pin', False) ; Update the ini file GUICtrlSetState($idLbl_Move, $GUI_ENABLE) ; Enable the label, this allows the gui to be moved Else GUICtrlSetState($MenuItem_Pin, $GUI_CHECKED) $g_bPin = True ; Update the var IniWrite($g_sSetFile, 'Settings', 'Pin', True) ; Update the ini file GUICtrlSetState($idLbl_Move, $GUI_DISABLE) ; Disable the label, preventing the gui to be moved EndIf EndFunc ;==>MenuItem_PinClick Func hWnd_Close() ; First we check if it's Add, Edit or Delete event gui that send the msg Switch WinGetHandle('[ACTIVE]') ; The handle of the current gui Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent ; hide the addevent gui GUISetState(@SW_HIDE, $hAddEvent) Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent ; hide the editevent gui GUISetState(@SW_HIDE, $hEditEvent) Case WinGetHandle($hDeleteEvent) ; If its Delete event Local $iCtrlID = $idDelEvent ; hide the Delete event gui GUISetState(@SW_HIDE, $hDeleteEvent) Case WinGetHandle($hSettings) ; If its Settings ; Hide the gui GUISetState(@SW_HIDE, $hSettings) Return EndSwitch ; Clear all ; The first 3 ctrls is the same for all 3 gui's _GUICtrlComboBox_ResetContent($iCtrlID + 2) ; Clear the combo GUICtrlSetData($iCtrlID + 4, '') ; Clear the input Event name GUICtrlSetData($iCtrlID + 6, '') ; Clear the edit event Description ; Now we need to check if we have the edit or update gui If WinGetHandle($hAddEvent) Or WinGetHandle($hEditEvent) = WinGetHandle('[ACTIVE]') Then GUICtrlSetState($iCtrlID + 7, $GUI_UNCHECKED) ; Unchecks the Choose event date by calender checkbox GUICtrlSetData($iCtrlID + 9, '') ; Clear the input Days to event GUICtrlSetState($iCtrlID + 19, $GUI_UNCHECKED) ; Uncheck Save as default / Enabled checkbox Else ; Uncheck the Enabled checkbox at the delete gui GUICtrlSetState($iCtrlID + 19, $GUI_UNCHECKED) ; Uncheck Enabled checkbox EndIf EndFunc ;==>hWnd_Close Func idBtn_Sett_OKClick() ; Read infos and update the settings. ; Get maxEvents Local $iMaxEvents = GUICtrlRead($idInp_Sett_MaxEvents) If $iMaxEvents = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Max number of events', _ "The input Max number of events is empty, but it shouldn't be" & @CRLF & 'Please type number of max allowed events!!') GUICtrlSetState($idInp_Sett_MaxEvents, $GUI_FOCUS) Else IniWrite($g_sSetFile, 'Settings', 'MaxEvents', $iMaxEvents) EndIf ; Write the settings to ini file IniWrite($g_sSetFile, 'Settings', 'Remember', (GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'SoundPlay', (GUICtrlRead($idCb_Sett_PlaySound) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'Popup', (GUICtrlRead($idCb_Sett_Pop) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'StartWithWin', (GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED) ? True : False) IniWrite($g_sSetFile, 'Settings', 'SoundFile', GUICtrlRead($idInp_Sett_Sound)) ; Check if the program should rember it's last position If GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED Then PosSave() ; Check if the program should start with windows If GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED Then RegWrite('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CCD', 'REG_SZ', '"' & @ScriptFullPath & '"') Else RegDelete('HKCU\Software\Microsoft\Windows\CurrentVersion\Run', 'CCD') EndIf ; Update the global vars $g_bRemember = (GUICtrlRead($idCb_Sett_Remember) = $GUI_CHECKED) ? True : False $g_bSoundPlay = (GUICtrlRead($idCb_Sett_PlaySound) = $GUI_CHECKED) ? True : False $g_bPopup = (GUICtrlRead($idCb_Sett_Pop) = $GUI_CHECKED) ? True : False $g_bStartWithWin = (GUICtrlRead($idCb_Sett_StartWithWin) = $GUI_CHECKED) ? True : False $g_sSoundFile = GUICtrlRead($idInp_Sett_Sound) GUISetState(@SW_HIDE, $hSettings) EndFunc ;==>idBtn_Sett_OKClick Func idBtn_Sett_RemEventClick() ; First we warn about the removal Local $iStyle = BitOR($MB_YESNO, $MB_SETFOREGROUND, $MB_TOPMOST, $MB_ICONWARNING) Local $sEvent = GUICtrlRead($idList_Sett_DefEvents) Local $iMsgBoxAnswer = MsgBox($iStyle, 'Delete event', 'The event "' & $sEvent & '" will be deletede!' & @CRLF & "Do you want to continue?") Switch $iMsgBoxAnswer Case $IDYES ; Remove the evetn from ini file IniDelete($g_sSetFile, _StringToHex($sEvent)) ; Remove selected from the list box _GUICtrlListBox_DeleteString($idList_Sett_DefEvents, _GUICtrlListBox_FindString($idList_Sett_DefEvents, $sEvent)) Case $IDNO Return EndSwitch EndFunc ;==>idBtn_Sett_RemEventClick Func idCb_ChoseDateClick() ; Handel the Choose by date checkbox for either Add or Edit event gui ; First we check if it's Add or Edit event gui that is asking Switch WinGetHandle('[ACTIVE]') ; The handle of the current gui Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent EndSwitch ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($iCtrlID + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Hide, disable and clear days and time input / label GUICtrlSetState($iCtrlID + 8, $GUI_HIDE) ; Hide the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the input Days to event GUICtrlSetData($iCtrlID + 9, '') ; Clear the input Days to event GUICtrlSetState($iCtrlID + 10, $GUI_HIDE) ; Hides the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the TimePicker Time to event ; Show date picker and lable GUICtrlSetState($iCtrlID + 12, $GUI_SHOW) ; Show the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show the Date time picker Case False ; Hide, disable and clear date picker and label GUICtrlSetState($iCtrlID + 12, $GUI_HIDE) ; Hide the label Event date GUICtrlSetState($iCtrlID + 13, BitOR($GUI_DISABLE, $GUI_HIDE)) ; Hide the Date time picker ; Enable, show and set time input / labels GUICtrlSetState($iCtrlID + 8, $GUI_SHOW) ; Show the label Days to event GUICtrlSetState($iCtrlID + 9, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Shows the Input Days to event GUICtrlSetState($iCtrlID + 10, $GUI_SHOW) ; Shows the label Time to event GUICtrlSetState($iCtrlID + 11, BitOR($GUI_ENABLE, $GUI_SHOW)) ; Show time picker EndSwitch EndFunc ;==>idCb_ChoseDateClick Func idBtn_AddEventClick() ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idAddEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idAddEvent + 4, $GUI_FOCUS) Return EndIf ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($idAddEvent + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idAddEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idAddEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idAddEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idAddEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch Local $sEvent = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC ; We use this to prevent events with same SectionNames in the ini file. ; Create an array to hold the Event values Local $aValues[8][2] $aValues[0][0] = 7 ; Number of elements in the array $aValues[0][1] = '' $aValues[1][0] = 'Name' $aValues[1][1] = $sReadName ; Event Name $aValues[2][0] = 'Description' $aValues[2][1] = StringReplace(GUICtrlRead($idAddEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3][0] = 'EndDate' $aValues[3][1] = $sDTS ; Event end date $aValues[4][0] = 'Sound' $aValues[4][1] = GUICtrlRead($idAddEvent + 15) ; Get sound to play from input sound to play $aValues[5][0] = 'PlaySound' $aValues[5][1] = (GUICtrlRead($idAddEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6][0] = 'Popup' $aValues[6][1] = (GUICtrlRead($idAddEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7][0] = 'Enabled' $aValues[7][1] = 'True' ; The Event is Enabled by default IniWriteSection($g_sEventFile, $sEvent, $aValues) ; Write data to ini file ; Get state of save as default checkbox If GUICtrlRead($idAddEvent + 19) = $GUI_CHECKED Then ; We dont save all the info, only Days to Event, Sound to play, To play o not play the sound and to show or not to show the popup ; Trim the array from unneeded data _ArrayDelete($aValues, '1;7') ; Remove Name and Enabled $aValues[0][0] = 5 ; Update the number of values left in the array $aValues[2][0] = 'Days' ; Change EndDate to Days ; Get the amount of days to event +1 course the cal is only returing whole days and the event will be in x days and 23:59:xx sec ; There for we needs to ad +1, so it will correspond to the amount of days th euser might have entered in Days to Event $aValues[2][1] = _DateDiff('D', _NowCalc(), $sDTS) + 1 IniWriteSection($g_sSetFile, _StringToHex(GUICtrlRead($idAddEvent + 4)), $aValues) ; Write the info to Settings file EndIf hWnd_Close() ; Close the gui If $g_aEvents[1] = Null Then UpdateGui(True) ; Update Countdown GUI with Msg Else UpdateGui(False) ; Update Countdown GUI without msg EndIf EndFunc ;==>idBtn_AddEventClick Func idBtn_UpdateEventClick() ; First we read the combo to get the index of the selected event Local $iIndex = _GUICtrlComboBox_GetCurSel($idEditEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) ; First we handle the inputs etc. ; Read data from gui, and add it to an array Local $sReadName = GUICtrlRead($idEditEvent + 4) ; Read name from Event name input If $sReadName = '' Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Event Name Error', 'The input "Event name" was empty!' & _ @CRLF & 'Please enter type an Event name!!') GUICtrlSetState($idEditEvent + 4, $GUI_FOCUS) Return EndIf ; Get state of checkbox Local $bChoseDate = (GUICtrlRead($idEditEvent + 7) = $GUI_CHECKED) ? True : False ; Handel state of checkbox Switch $bChoseDate Case True ; Get DTS from date picker Local $sDTS = GUICtrlRead($idEditEvent + 13) Case False ; Check that days is not empty Local $sReadDays = GUICtrlRead($idEditEvent + 9) If $sReadDays <> '' Then Local $sDTS = CalcEndDate($sReadDays, GUICtrlRead($idEditEvent + 11)) Else MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Days Error', 'The input "Days to event" was empty!' & _ @CRLF & 'Please enter number of days!!') GUICtrlSetState($idEditEvent + 9, $GUI_FOCUS) Return EndIf EndSwitch ; Create an array to hold the Event values Local $aValues[8][2] $aValues[0][0] = 7 ; Number of elements in the array $aValues[0][1] = '' $aValues[1][0] = 'Name' $aValues[1][1] = $sReadName ; Event Name $aValues[2][0] = 'Description' $aValues[2][1] = StringReplace(GUICtrlRead($idEditEvent + 6), @CRLF, ' ') ; Get data from edit $aValues[3][0] = 'EndDate' $aValues[3][1] = $sDTS ; Event end date $aValues[4][0] = 'Sound' $aValues[4][1] = GUICtrlRead($idEditEvent + 15) ; Get sound to play from input sound to play $aValues[5][0] = 'PlaySound' $aValues[5][1] = (GUICtrlRead($idEditEvent + 17) = $GUI_CHECKED) ? True : False ; To play or not play sound at event end $aValues[6][0] = 'Popup' $aValues[6][1] = (GUICtrlRead($idEditEvent + 18) = $GUI_CHECKED) ? True : False ; To show or not to show popup at event end $aValues[7][0] = 'Enabled' $aValues[7][1] = (GUICtrlRead($idEditEvent + 19) = $GUI_CHECKED) ? True : False ; If enabled or not enabled IniWriteSection($g_sEventFile, $aEvents[$iIndex], $aValues) ; Write data to ini file hWnd_Close() ; Close the gui UpdateGui(False) ; Update Countdown GUI EndFunc ;==>idBtn_UpdateEventClick Func idBtn_EventDeleteClick() ; Deletes the selected Event from the Events.ini file and if it's current active in the CountDown GUI ; refreshes the gui to remove it from that also ; First we warn the user that the event will be deletede If MsgBox(BitOR($MB_YESNO, $MB_TOPMOST, $MB_SETFOREGROUND, $MB_ICONWARNING), 'Delete Event', 'The Event ' & GUICtrlRead($idDelEvent + 2) & _ ' will be deletede!' & @CRLF & 'Do you want to continue?') = $IDNO Then Return ; Read the combo, to get the index of the selected Event Local $iIndex = _GUICtrlComboBox_GetCurSel($idDelEvent + 2) + 1 ; Add +1 to the index ; Now we get the sectionnames from the ini file Local $aEvents = IniReadSectionNames($g_sEventFile) ; Saves the sectionname that we need to delete Local $sEventToDelete = $aEvents[$iIndex] ; We deletes the event from the ini file IniDelete($g_sEventFile, $aEvents[$iIndex]) ; Closes the Delete event gui GUISwitch($hDeleteEvent) hWnd_Close() ; Check if the event is active in the CountDownGUI, by checking if it's located in the EventData array. ; We search for the "SectionName" in the aEventData array, at colum 3, sins Col 1 holds the enddate and col 2 holds Enabled If _ArraySearch($g_aEventData, $sEventToDelete, 0, 0, 0, 0, 1, 3) <> -1 Then UpdateGui(False) ; Check if Max events is lessere that current enabled events EventOnLoad(False) If $g_aEvents[0] < $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_ENABLE) EndFunc ;==>idBtn_EventDeleteClick Func idBtn_SoundBrowseClick() ; First we check if it's Add, Edit Event or Settings gui that is asking Switch WinGetHandle('[ACTIVE]') Case WinGetHandle($hAddEvent) ; If its Add event Local $iCtrlID = $idAddEvent Case WinGetHandle($hEditEvent) ; If its Edit event Local $iCtrlID = $idEditEvent Case WinGetHandle($hSettings) ; If it Settings Local $iCtrlID = $idInp_Sett_Sound - 15 ; We have a ctrlid for this, so we subtracts 15 from the id to match our input. EndSwitch ; Display an open dialog to select a list of file(s). Local $iExStyle = BitOR($OFN_PATHMUSTEXIST, $OFN_FILEMUSTEXIST) Local $sAudioFile = _WinAPI_OpenFileDlg('', @WorkingDir, 'Audio (*.wav;*.mp3)', 1, '', '', $iExStyle) ; We only add if there is something to add If $sAudioFile <> '' Then GUICtrlSetData($iCtrlID + 15, $sAudioFile) EndFunc ;==>idBtn_SoundBrowseClick Func idCombo_EventsChange() ; Here we handle the combo changes for Add,Edit and Delete events ; First we check if it's Add or Edit event gui that is asking Switch WinGetHandle('[ACTIVE]') ; Get winhandl from active GUI Case WinGetHandle($hAddEvent) ; If it's Add event ; If we have the Add Event gui ; First we read the combo Local $sRead = GUICtrlRead($idAddEvent + 2) ; Now we get the default event data from the settings ini file Local $aData = IniReadSection($g_sSetFile, _StringToHex($sRead)) ; Add the data to the inputs GUICtrlSetData($idAddEvent + 4, $sRead) ; Add Name of event to input GUICtrlSetData($idAddEvent + 6, $aData[1][1]) ; Add Description to the edit GUICtrlSetData($idAddEvent + 9, $aData[2][1]) ; Add number of days to input GUICtrlSetData($idAddEvent + 15, $aData[3][1]) ; Add sound to input ; Set the state of Soundplay CbSetState($idAddEvent + 17, StringToType($aData[4][1])) ; Set the state of popup checkbox CbSetState($idAddEvent + 18, StringToType($aData[5][1])) Case WinGetHandle($hEditEvent) ; If it's Edit event ; We have the edit event gui ; First we read the combo Local $iIndex = _GUICtrlComboBox_GetCurSel($idEditEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) Local $aData = IniReadSection($g_sEventFile, $aEvents[$iIndex]) ; Add the data to the inputs GUICtrlSetData($idEditEvent + 4, $aData[1][1]) ; Add the name to Event Name input GUICtrlSetData($idEditEvent + 6, $aData[2][1]) ; Add Description GUICtrlSetData($idEditEvent + 13, $aData[3][1]) ; Add end date of event GUICtrlSetData($idEditEvent + 15, $aData[4][1]) ; Add the sound GUICtrlSetTip($idEditEvent + 15, $aData[4][1]) ;Update the state of the checkboxes CbSetState($idEditEvent + 17, StringToType($aData[5][1])) ; PlaySound checkbox CbSetState($idEditEvent + 18, StringToType($aData[6][1])) ; Popup Checkbox CbSetState($idEditEvent + 19, StringToType($aData[7][1])) ; Enabled checkbox Case WinGetHandle($hDeleteEvent) ; If it's Delete event ; We have the edit event gui ; First we read the combo Local $iIndex = _GUICtrlComboBox_GetCurSel($idDelEvent + 2) + 1 ; Now we get the data from the inifile Local $aEvents = IniReadSectionNames($g_sEventFile) Local $aData = IniReadSection($g_sEventFile, $aEvents[$iIndex]) ; Add the data to the inputs GUICtrlSetData($idDelEvent + 4, $aData[1][1]) ; Add the name to Event Name input GUICtrlSetData($idDelEvent + 6, $aData[2][1]) ; Add Description GUICtrlSetData($idDelEvent + 8, $aData[3][1]) ; Add end date of event CbSetState($idDelEvent + 9, StringToType($aData[7][1])) ; Enabled checkbox EndSwitch EndFunc ;==>idCombo_EventsChange Func UpdateGui($bStart = True) ; Adds events to the main gui ; Check if we have an event to add to the gui If $g_aEvents[1] = Null And $bStart = False Then Return ; If we don't have any events ; If the function is called with False, we deletes all controls If $bStart = False Then ; Delete existing controls, so we can recreate them For $i = 1 To $g_aEvents[0] GUICtrlDelete($g_idLbl_Event[$i]) ; Delete the Event Name Label GUICtrlDelete($g_idLbl_Days[$i]) ; Deletes the label Days Counter GUICtrlDelete($g_idLbl_Days[$i] + 1) ; Deletes the label Days GUICtrlDelete($g_idLbl_Hrs[$i]) ; Deletes the label Hrs counter GUICtrlDelete($g_idLbl_Hrs[$i] + 1) ; Deletes the label : after hrs GUICtrlDelete($g_idLbl_Min[$i]) ; Deletes the label min counter GUICtrlDelete($g_idLbl_Min[$i] + 1) ; Deletes the label : after min GUICtrlDelete($g_idLbl_Sec[$i]) ; Deletes the label sec counter GUICtrlDelete($g_idLbl_Sec[$i] + 1) ; Deletes the label we use as frame around the time counter GUICtrlDelete($g_idLbl_Sec[$i] + 2) ; Deletes the Group we use as spacer GUICtrlDelete($g_idLbl_Sec[$i] + 3) ; Deletes the label we use as a frame for the gui Next EndIf $g_aEvents = IniReadSectionNames($g_sEventFile) ; reload the array ; Check if there is any events If Not IsArray($g_aEvents) Then Dim $g_aEvents[2] = [1, Null] Return EndIf ; Trims disabled events EventOnLoad(False) ; We call the function with false to prevent the msg box about too many events. ; Just to be shure If $g_aEvents[1] = Null Then Return ; Updates the global GUIHeight $g_iGuiHeight = ($g_iSpace * $g_aEvents[0]) + 8 ; Switch to the CCD gui, else the labels would be created on the last active gui GUISwitch($hCountdownDays) For $i = 1 To $g_aEvents[0] ; Adds the events to the Countdown gui Local $sEventName = StringLeft(IniRead($g_sEventFile, $g_aEvents[$i], 'Name', ''), 24) $g_idLbl_Event[$i] = GUICtrlCreateLabel($sEventName, 8, 14 + (($i - 1) * $g_iSpace), 119, 20, $SS_CENTER) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") GUICtrlSetColor(-1, 0xFFFFFF) ; Navy blue GUICtrlSetTip(-1, SplitText(IniRead($g_sEventFile, $g_aEvents[$i], 'Description', ''), 45)) $g_idLbl_Days[$i] = GUICtrlCreateLabel("", 31, 34 + (($i - 1) * $g_iSpace), 32, 24, $SS_RIGHT) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel("Days", 65, 34 + (($i - 1) * $g_iSpace), 34, 24) GUICtrlSetFont(-1, 14, 400, 0, "Arial Narrow") $g_idLbl_Hrs[$i] = GUICtrlCreateLabel("", 22, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 46, 56 + (($i - 1) * $g_iSpace), 8, 24) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Min[$i] = GUICtrlCreateLabel("", 56, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") GUICtrlCreateLabel(":", 80, 56 + (($i - 1) * $g_iSpace), 8, 24) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") $g_idLbl_Sec[$i] = GUICtrlCreateLabel("", 90, 56 + (($i - 1) * $g_iSpace), 18, 24, $SS_CENTER) GUICtrlSetFont(-1, 14, 800, 0, "Arial Narrow") ; Create a static lable to frame the Time countdown GUICtrlCreateLabel("", 16, 56 + (($i - 1) * $g_iSpace), 102, 24, BitOR($SS_GRAYFRAME, $WS_DISABLED, $SS_SUNKEN)) ; We add a horizontal line as a spacer between the events, but only if we have more that one. But we don't add one after the last If $i >= 1 And $i < $g_aEvents[0] And $g_aEvents[0] > 1 Then GUICtrlCreateGroup("", 0, 84 + (($i - 1) * $g_iSpace), 135, 9) GUICtrlCreateGroup("", -99, -99, 1, 1) EndIf $g_idLbl_Event[0] = $i Next ; Resizes the Frame label GUICtrlSetPos($idFrame, 0, 0, 136, $g_iGuiHeight) ; Get the position of the Countdown gui Local $aWinPos = WinGetPos($hCountdownDays) ; Updates the height of the Countdown gui, using the pos we got, and the new height using the updated global guiheight _WinAPI_SetWindowPos($hCountdownDays, $HWND_NOTOPMOST, $aWinPos[0], $aWinPos[1], 136, $g_iGuiHeight, $SWP_NOMOVE) ; Finaly we checks if we have exceeded or maxed out the allowed amounts of Events. ; If we have we disables the add event MenuItem, thereby preventing the user to add more events, until ; an Event is either disabled or deleted, making up space for a new one. If $g_aEvents[0] >= $g_iMaxEvents Then GUICtrlSetState($MenuItem_AddEvent, $GUI_DISABLE) EndFunc ;==>UpdateGui Func CbSetState($iCtrlID, $bEnabled) Switch $bEnabled ; Popup checkbox Case True GUICtrlSetState($iCtrlID, $GUI_CHECKED) Case False GUICtrlSetState($iCtrlID, $GUI_UNCHECKED) EndSwitch EndFunc ;==>CbSetState Func PosSave() Local $aPos = WinGetPos($hCountdownDays) IniWrite($g_sSetFile, 'Settings', 'Posx', $aPos[0]) IniWrite($g_sSetFile, 'Settings', 'Posy', $aPos[1]) EndFunc ;==>PosSave Func Countdown() If $g_aEvents[1] = Null Then Return ; If we don't have any events For $i = 1 To $g_aEvents[0] ; cycle through events Local $iGetSec = _DateDiff('s', _NowCalc(), $g_aEventData[$i][0]) ; grab seconds of difference from now to future date If $iGetSec <= 0 And $g_aEventData[$i][1] = True Then EventHandle($g_aEvents[$i], $i) EndIf Ticks_To_Time($iGetSec, $g_iDays, $g_iHours, $g_iMins, $g_iSecs) ; convert seconds to days/hours/minutes/seconds ; set color and data Switch $g_iDays Case 0 To 5 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 1) ; Red Case 6 To 10 GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 2) ; Yellow Case Else GUICtrlSetDataAndColor($g_idLbl_Days[$i], $g_iDays, 3) ; Green EndSwitch ; If days = 0 we want to change the timer colors If $g_iDays = 0 Then Switch $g_iHours Case 0 To 6 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 1) ; Red GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 1) ; Red GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 1) ; Red Case 7 To 12 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 2) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 2) ; Yellow GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 2) ; Yellow Case 13 To 23 GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours, 3) ; Green GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins, 3) ; Green GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs, 3) ; Green EndSwitch Else ; If not we just keep them black GUICtrlSetDataAndColor($g_idLbl_Hrs[$i], $g_iHours) ; Black GUICtrlSetDataAndColor($g_idLbl_Min[$i], $g_iMins) ; Black GUICtrlSetDataAndColor($g_idLbl_Sec[$i], $g_iSecs) ; Black EndIf Next EndFunc ;==>Countdown Func EventHandle($sEvent, $iIndex) ; Here we handles the event when it's time is up o_O ; First we disable the event, to prevent it from caling this function more than once. IniWrite($g_sEventFile, $sEvent, 'Enabled', False) ; Set False in the ini file $g_aEventData[$iIndex][1] = False ; Update the EventData array from True to false ; We need to check if the we should play a sound and / or throw a popup Local $aData = IniReadSection($g_sEventFile, $sEvent) ; Error checker If @error Then MsgBox(BitOR($MB_ICONERROR, $MB_SETFOREGROUND, $MB_TOPMOST), 'Error reading event data', 'An error happend when trying to read the event data!' _ & @CRLF & 'The program will now close!!') Exit EndIf ; Check if a sound should be played If StringToType($aData[5][1]) = True Then SoundPlay($aData[4][1]) ; Check if a popup should be displayed If StringToType($aData[6][1]) = True Then ; Disable the on event mode, else the GuiGetMsg won't work Opt("GUIOnEventMode", 0) ; Create the popup window Local $iStyle = BitOR($WS_SYSMENU, $WS_POPUP, $DS_SETFOREGROUND, $WS_CAPTION) Local $iExStyle = BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW) Local $hPopup = GUICreate($aData[1][1], 405, 285, Default, Default, $iStyle, $iExStyle) Local $idEdit_Popup = GUICtrlCreateEdit("", 11, 8, 385, 233, BitOR($ES_CENTER, $ES_READONLY, $ES_WANTRETURN, $WS_VSCROLL)) ; Set the Event description test to the edit GUICtrlSetData(-1, @CRLF & SplitText($aData[2][1]), 45) ;~ GUICtrlSetBkColor(-1, 0x4E4E4E) GUICtrlSetFont(-1, 18, 800, 0, "Arial Narrow") ; Boost the font size Local $idBtn_OK = GUICtrlCreateButton("OK", 165, 256, 75, 21, $BS_DEFPUSHBUTTON) GUISetState(@SW_SHOW) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE SoundPlay('') ; Kill the sound if any GUIDelete($hPopup) ; Delete the gui ExitLoop ; And exit loop Case $idBtn_OK SoundPlay('') ; Kill the sound if any GUIDelete($hPopup) ; Delete the gui ExitLoop ; And exit loop EndSwitch WEnd Opt("GUIOnEventMode", 1) ; Reenable OnEventMode EndIf ; Set background label of the event to Yellow and text to Red - Indicate that the event is up GUICtrlSetColor($g_idLbl_Event[$iIndex], $COLOR_RED) ; Red GUICtrlSetBkColor($g_idLbl_Event[$iIndex], $COLOR_YELLOW) ; Yellow GUICtrlSetData($g_idLbl_Sec[$iIndex], '00') ; And set sec to 00 just becorse EndFunc ;==>EventHandle Func Ticks_To_Time($iSeconds, ByRef $idays, ByRef $iHours, ByRef $iMins, ByRef $iSecs) ; second conversion. ; modified: added days. added format style, to use 00 for time If Number($iSeconds) > 0 Then $idays = Int($iSeconds / 86400) $iSeconds = Mod($iSeconds, 86400) $iHours = StringFormat("%02d", Int($iSeconds / 3600)) $iSeconds = Mod($iSeconds, 3600) $iMins = StringFormat("%02d", Int($iSeconds / 60)) $iSecs = StringFormat("%02d", Mod($iSeconds, 60)) Return 1 Else Return SetError(1, 0, 0) EndIf EndFunc ;==>Ticks_To_Time Func GUICtrlSetDataAndColor($hWnd, $iCount, $iColor = 0) ; Set Day(s), Hour(s), Min(s), Sec(s) and color to the countdown labels Local $dRed, $dYellow, $dGreen, $dBlack Switch $iColor ; Check if we chould use a color Case 0 ; Black <- Default color $dBlack = 0x000000 Case 1 ; Red $dRed = 0xFF0000 Case 2 ; Yellow $dYellow = 0xFFFF00 Case 3 ; Green $dGreen = 0x008000 EndSwitch If GUICtrlRead($hWnd) <> $iCount Or GUICtrlRead($hWnd) = '' Then ; if data is different then change. helps with flickering GUICtrlSetData($hWnd, $iCount) GUICtrlSetColor($hWnd, $dRed & $dYellow & $dGreen & $dBlack) EndIf EndFunc ;==>GUICtrlSetDataAndColor Func CalcEndDate($idays, $sTime) ; Calculates a new date by adding a specified number of Days to an initial date Return _DateAdd('D', $idays, @YEAR & '/' & @MON & '/' & @MDAY & ' ' & $sTime) EndFunc ;==>CalcEndDate Func StringToType($vData) ; Converts a string to bool, Number or KeyWord Local $aData = StringRegExp($vData, "(?i)\bTrue\b|\bFalse\b|\bNull\b|\bDefault\b|\d{1,}", 3) If Not IsArray($aData) Then Return $vData Switch $aData[0] Case 'True' Return True Case 'False' Return False Case 'Null' Return Null Case 'Default' Return Default Case Else Return Number($aData[0]) EndSwitch EndFunc ;==>StringToType Func SplitText($sString, $iLenght = 45) #cs This splits a large text up into cunks at N lengt, at the last space within the nLength specified, and seperated with a @CRLF eg. 'A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." Would be formated as this: A child asked his father, "How were people born?" So his father said, "Adam and Eve made babies, then their babies became adults and made babies, and so on." #ce Local $sResult = StringRegExpReplace($sString, ".{1," & $iLenght - 1 & "}\K(\s{1,2}|$)", @CRLF) Return $sResult EndFunc ;==>SplitText
  23. @InunoTaishou Have you checked under settings? You can unchek auto complet there. Cheers /Rex
  24. @ISI360 Is in PM Cheers /Rex
×
×
  • Create New...