Search the Community
Showing results for tags 'guictrlcreateradio'.
Found 2 results
I am working on a script that pulls the current time from the internet and then reads contents from our backup server based on the month and week folders that are already created. This script will ultimate pass variables to another program that will restore the data from the respective folder to the computer that the script it running on. The script is built to find the 'windows' folders in the server structure which is \\server\serverfolder\01_16\3week \\server\serverfolder - is the server share 01_16 - is month and year as to sort properly 3week - is obviously the week Within the week folder there are user folders (eg. bsmith, jdoe, ganderson), in these folders are backups of full hard drives with include the windows folder which we are looking for.The script is running and is fully function the first time that it is run. I have also added a back button so if for some reason you are in the wrong list of folders you can navigate to the correct folder and then show the results again. The issue I am having is that I can show the contents and everything works well, unless I use the back button and navigate to a different set of folders (different week). The radio buttons do not respond properly. They will show both incorrect data and the count of radio buttons is not being updated. I have attempted to look for a solution and have tried many different ideas, but I just don't fully understand how a GUICtrlCreateRadio in a for loop with GUICtrlSetOnEvent should work. Any suggestions would be greatly appreciated. I apologize for the messy code. #include <Array.au3> #include <File.au3> #include <GUIConstantsEx.au3> ; #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 $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 = ['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 ; Loop through the array returned by StringSplit to display the individual values. ; MsgBox(4096, "", "$aDays[" & $i & "] - " & $aDays[$i]) ; Next $CurrentMonthFolder = $ServerPath & $aDays & "_" & StringTrimLeft($aDays, 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 For $i = 1 To $aFileList $Current_Radiou = GUICtrlCreateRadio($aFileList[$i], 25, $startline + 20 * $i, 400) GUICtrlSetOnEvent(-1, "myEvent") ; This will tell us which radio was clicked Next EndIf 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() For $x = 1 To $aFileList + 6 ; this is broken If GUICtrlRead($x) = 1 Then MsgBox(0, GUICtrlRead($x), GUICtrlRead($x, 1)) ;this is the path to the profile Next 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
Hey everyone. looking for some quick answer to this-- I'm using couple of radio buttons created via GUICtrlCreateRadio function. My intent is to have one of those selected by default upon program launch, can this be achieved & if yes, how. thanks in advance..