Jump to content

byarotsky

Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Location
    Canada

byarotsky's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. 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[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 For $i = 1 To $aFileList[0] $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[0] + 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
  2. Thank you for the reply. We have been using the offline updater at our shop for probably 6 years. It does work way better than chewing up all of your internet bandwidth. But I find that you need to run it many times to get all of the updates installed properly and it doesn't like to reboot and reconnect properly when run from a network share. I did actually get a similar script running to the above one (as far as I can tell). It was something so stupid that I was struggling with, it needs #RequireAdmin. We have decided to go down the road of a WSUS server that we redirect to on every machine from our computer cleaning / setup software. Then the updater script just hammers away at the updates until done. Once complete it changes back to the Windows update server and completes again. We just started testing, so we will see how it goes. Might end up going back to the offline updater. thanks Brad
  3. hello I have been playing with existing script to try and get windows updates to reliable install on Windows 7, 8 and 8.1. I am also getting object errors. It seems to work on some and not on others. I was just wondering if you were able to get your script working properly. Thanks Brad
  4. Thank you. This is looking very close to what I am looking for. I will pick it apart later this week. Brad
  5. Sorry, I have corrected the posted code. Can anyone shed any light on this? Thanks Brad
  6. I am attempting to build a script that will pull jpg files from my external device, copy local, resize and change orientation and move to the server is serveral places. Part of the script I would like to have a preview screen to check off the files that I want to process. I have taken some examples and tried to manipulate to do what I want, but I am struggling to get my list of images to show properly. Basically in this test I would like to read list of files from folder Generate a screen with thumbnails and a corresponding checkbox Each thumbnail will show a different file in the folder Currently I am only able to show either the last image in the first location and the rest are blank or all images are the same picture. Also I haven't even tried getting more than one line of images (fill the screen). Any help would be greatly appreciated. Thanks Brad #include <GDIPlus.au3> #include <Array.au3> #include <File.au3> Global $ImgPath = "C:Documents and SettingsOwnerDesktopTest2" Local $hGui, $iPic, $hGraphic, $hBitmap, $hImage $hGui = GUICreate("", @DesktopWidth, @DesktopHeight) $iPic = GUICtrlCreatePic("", 0, 25, @DesktopWidth, 25) $ImgHeight = 133 $ImgWidth = 133 $ImgSpacing = 10 Local $localfile = _FileListToArray($ImgPath, "*.jpg", 1) ; List all jpg files in last folder _ArrayDelete($localfile, 0) _ArraySort($localfile) ;_ArrayDisplay($localfile) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $hBitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopWidth, $ImgHeight, $hGraphic) _GDIPlus_GraphicsDispose($hGraphic) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hBitmap) While UBound($localfile) $PopFileName = _ArrayPop($localfile) For $i = 0 To @DesktopWidth - $ImgWidth Step $ImgWidth + $ImgSpacing $hImage = _GDIPlus_ImageLoadFromFile ($ImgPath & $PopFileName) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $i + $ImgSpacing , 0, $ImgWidth, $ImgHeight) GUICtrlCreateCheckbox($PopFileName, $i + $ImgSpacing , $ImgHeight + 25, 120, 20) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) Next WEnd $hImage = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, 0, $hImage)) _GDIPlus_ShutDown() GUISetState(@SW_SHOW, $hGui) While GUIGetMsg() <> -3 WEnd
×
×
  • Create New...