#include #include #include ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetTimeOnline ; Description ...: Retrieve the current date and time from TimeAPI.org. ; Syntax ........: _GetTimeOnline($iTimeZone) ; Parameters ....: $iTimeZone - An integer value of the timezone . ; 0 - UTC (Universal Time) ; 1 - EST (Eastern Time) ; 2 - CST (Central Time) ; 3 - MST (Mountain Time) ; 4 - PST (Pacific Time) ; 5 - AKST (Alaska Time) ; 6 - HAST (Hawaii-Aleutian Time) ; Return values .: Success: Returns the current Date and Time in the format YYYY/MM/DD HH:MM:SS ; Failure: Sets @error to non-zero and returns the same format as a successful return but using the system time. ; Author ........: guinness ; Link ..........: According to http://www.programmableweb.com/api/timeapi, this is for non-commercial use. ; Example .......: Yes ; =============================================================================================================================== Opt("GUIResizeMode", 1) Opt("GUIOnEventMode", 1) Global $aRadioIDs[1] $aRadioIDs[0]=0 Global $vGUI_V = 450 Global $vGUI_ = 400 Local $ServerPath = "\\vault\backups\" Local $aFileList, $Current_Radio, $CurrentMonthFolder Local $Current_Gui = GUICreate("Test", 450, 400) Local $GuiBack = GUICtrlCreateButton("Back", 200, 250, 40, 40) GUICtrlCreateLabel("Please select the Windows folder to use", 20, 20) GUICtrlSetOnEvent($GuiBack, "BackPressed") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") ;_GetTimeOnline(2) ;Central time zone _SelectFolder() While 1 Sleep(100) WEnd Exit Func _GetTimeOnline($iTimeZone) ; Retrieve the current time from TimeAPI.org. Ideal if your Windows clock is out of sync. Local $aTimeZone[7] = ['utc', 'est', 'cst', 'mst', 'pst', 'akst', 'hast'] Local $sRead = BinaryToString(InetRead('http://www.timeapi.org/' & $aTimeZone[$iTimeZone] & '/now?format=\Y/\m/\d%20/\H:\M:\S')) If @error Then SetError(1, 0, @YEAR & '/' & @MON & '/' & @MDAY & '/' & @HOUR & ':' & @MIN & ':' & @SEC) EndIf Local $aDays = StringSplit($sRead, "/") ; Split the string of days using the delimiter "," and the default flag value. ; For $i = 1 To $aDays[0] ; Loop through the array returned by StringSplit to display the individual values. ; MsgBox(4096, "", "$aDays[" & $i & "] - " & $aDays[$i]) ; Next $CurrentMonthFolder = $ServerPath & $aDays[2] & "_" & StringTrimLeft($aDays[1], 2) & "\" & Ceiling((@MDAY + (7 - @WDAY)) / 7) & "week" EndFunc ;==>_GetTimeOnline Func _SelectFolder() Local Const $sMessage = "Select users folder to restore data from:" ; Display an open dialog to select a file. Local $sFileSelectFolder = FileSelectFolder($sMessage, $CurrentMonthFolder) If @error Then ; Display the error message. ; MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Exit Else ; Display the selected folder. ; MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) $aFileList = _FileListToArrayRec($sFileSelectFolder, "Windows", 14, -3, $FLTAR_SORT) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid or Windows folder not found.") _SelectFolder() EndIf If @error = 9 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") _SelectFolder() EndIf EndIf $CurrentMonthFolder = $sFileSelectFolder _ShowGui() EndFunc ;==>_SelectFolder Func _ShowGui() Local $startline = 20 If @error Then MsgBox(4096, "ERROR", "Error occured, no INI or incorrect Sections") Else If IsArray($aRadioIDs) Then _ArrayDisplay($aRadioIDs,'Before Deleting') ConsoleWrite($aRadioIDs[0] & @CRLF) If $aRadioIDs[0] > 0 Then For $i = $aRadioIDs[0] to 1 Step -1 ConsoleWrite($i & ': deleting' & @CRLF) GUICtrlDelete($aRadioIDs[$i]) _ArrayDelete($aRadioIDs, $i) Next EndIf EndIf $aRadioIDs[0]=0 ReDim $aRadioIDs[$aFileList[0] + 1] For $i = 1 To $aFileList[0] $aRadioIDs[$i] = GUICtrlCreateRadio($aFileList[$i], 25, $startline + 20 * $i, 400) GUICtrlSetOnEvent(-1, "myEvent") ; This will tell us which radio was clicked Next EndIf $aRadioIDs[0] = $aFileList[0] _ArrayDisplay($aRadioIDs) GUISetState(@SW_SHOW, $Current_Gui) EndFunc ;==>_ShowGui Func BackPressed() ; MsgBox($MB_SYSTEMMODAL, "Go Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle & " CtrlHandle=" & @GUI_CtrlHandle) GUISetState(@SW_HIDE, $Current_Gui) _SelectFolder() EndFunc ;==>BackPressed Func myEvent() MsgBox(0, @GUI_CtrlId, GUICtrlRead(@GUI_CtrlId, 1)) ;this way #comments-start or this way For $x = 1 To $aRadioIDs[0] If GUICtrlRead($aRadioIDs[$x]) = 1 Then MsgBox(0, @GUI_CtrlId, GUICtrlRead($aRadioIDs[$x], 1)) ;this is the path to the profile Next #comments-end EndFunc ;==>myEvent Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE ; MsgBox($MB_SYSTEMMODAL, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE ; MsgBox($MB_SYSTEMMODAL, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Case @GUI_CtrlId = $GUI_EVENT_RESTORE ; MsgBox($MB_SYSTEMMODAL, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents