ken82m Posted November 18, 2008 Share Posted November 18, 2008 (edited) Too much damn code so I'm just gonna upload a rar with the au3 and 3 supporting au3's lol Just run the one marked "main" It will call the other two files which create the GUI's I think the problem is just in the "Main" one but you need it all to get the GUI up and see the problem. Here's the problem the script initially runs GUI comes up, fast no problem. Initially everything will be grayed out except the "Backup Scheme" fropdown at the top and the "Enable archive" checkbox in the bottom left. Changing the first will enable different controls depending on the option. Checking the second will just enable the button next to it. In either case you will see a second or two delay for the changes to become visible, it seems to vary. After that you can check/uncheck change those controls all day long and it updates immediately. anyone have any ideas? Thanks, Kenny Edited November 18, 2008 by ken82m "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 18, 2008 Share Posted November 18, 2008 Too much damn code so I'm just gonna upload a rar with the au3 and 3 supporting au3's lolJust run the one marked "main" It will call the other two files which create the GUI'sI think the problem is just in the "Main" one but you need it all to get the GUI up and see the problem. Here's the problem the script initially runs GUI comes up, fast no problem.Initially everything will be grayed out except the "Backup Scheme" fropdown at the topand the "Enable archive" checkbox in the bottom left.Changing the first will enable different controls depending on the option.Checking the second will just enable the button next to it.In either case you will see a second or two delay for the changes to become visible, it seems to vary.After that you can check/uncheck change those controls all day long and it updates immediately.anyone have any ideas?Thanks,KennyAre you running in GuiOnEventMode? If not, are there any Sleep() functions in your message loop?(No, there is zero chance I'm going to download and unpack files to find out...) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ken82m Posted November 18, 2008 Author Share Posted November 18, 2008 I usually use on eventmode but in this case I'm just using a message loop for whatever reason lol Sorry...Here's the code for the main script then: expandcollapse popupOpt("GUICloseOnESC", 0) Opt("TrayIconHide", 1) ;Required for functions #include<Date.au3> #include <Constants.au3> #include <CSVLibrary.au3> #include <Array.au3> ;GUI Constants #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;Create GUI Windows and Controls #include <MainGUI.au3> #include <ArchiveGUI.au3> ;Declare Global Variables Global $BackupRow = 0 Global $CleanupRow = 0 Global $TaskQuery ;Read Scheduled Tasks into array $TaskQuery = QueryJobs() ; How to Calculate End of Month: _DateAdd("D", -1, "2008/10/01") GUISetState(@SW_SHOW, $MainGUI) ;GUI Loop===================================================== While 1 $nMsg = GUIGetMsg(1) ;Main GUI===================================================== If $nMsg[0] = $GUI_EVENT_CLOSE And $nMsg[1] = $ArchiveGUI Then GUISetState(@SW_HIDE, $ArchiveGUI) GUISetState(@SW_SHOW, $MainGUI) Else Switch $nMsg[0] Case $GUI_EVENT_CLOSE Exit Case $Cancel Exit Case $BackupScheme BackupScheme() Case $BrowseButton GUISetState(@SW_DISABLE, $MainGUI) GUICtrlSetData($BrowseInput, FileSelectFolder("Select Backup Destination", "", 1, RegRead("HKLM\SOFTWARE\My Movies", "InstallPath")) & "\") If GUICtrlRead($BrowseInput) = "\" Then GUICtrlSetData($BrowseInput, "") GUISetState(@SW_ENABLE, $MainGUI) GUISetState(@SW_HIDE, $MainGUI) GUISetState(@SW_SHOW, $MainGUI) If GUICtrlRead($ArchiveDirInput) = GUICtrlRead($BrowseInput) AND GUICtrlRead($BrowseInput) <> "" Then GUICtrlSetData($BrowseInput, "") MsgBox(4096+16+262144, "Backup Directory Error", "The backup directory cannot be the same as your archive directory.") EndIf Case $ArchiveCheckbox If GUICtrlRead($ArchiveCheckbox) = $GUI_UNCHECKED Then GUICtrlSetState($ArchiveButton, $GUI_DISABLE) Else GUICtrlSetState($ArchiveButton, $GUI_ENABLE) EndIf Case $ArchiveButton GUISetState(@SW_HIDE, $MainGUI) GUISetState(@SW_SHOW, $ArchiveGUI) Case $ArchiveCheckbox ToggleArchive(1) Case $CreateJob Process() ;Archive GUI================================================== Case $ReturnToMain GUISetState(@SW_HIDE, $ArchiveGUI) GUISetState(@SW_SHOW, $MainGUI) Case $KeepFilesFor_CheckBox If GUICtrlRead($KeepFilesFor_CheckBox) = $GUI_UNCHECKED Then GUICtrlSetData($KeepDaysInput, 0) GUICtrlSetState($KeepDaysInput, $GUI_DISABLE) Else GUICtrlSetState($KeepDaysInput, $GUI_ENABLE) EndIf Case $ArchiveBrowse GUISetState(@SW_DISABLE, $ArchiveGUI) GUICtrlSetData($ArchiveDirInput, FileSelectFolder("Select Archive Folder", "", 1, GUICtrlRead($ArchiveDirInput)) & "\") If GUICtrlRead($ArchiveDirInput) = "\" Then GUICtrlSetData($ArchiveDirInput, "") GUISetState(@SW_ENABLE, $ArchiveGUI) GUISetState(@SW_HIDE, $ArchiveGUI) GUISetState(@SW_SHOW, $ArchiveGUI) If GUICtrlRead($ArchiveDirInput) = GUICtrlRead($BrowseInput) AND GUICtrlRead($ArchiveDirInput) <> "" Then GUICtrlSetData($ArchiveDirInput, "") MsgBox(4096+16+262144, "Archive Directory Error", "The archive directory cannot be the same as your backup directory.") EndIf Case $ArchiveCheckbox2 If GUICtrlRead($ArchiveCheckbox2) = $GUI_UNCHECKED Then ToggleArchive(0) Else ToggleArchive(1) EndIf EndSwitch EndIf WEnd ;GUI Loop===================================================== ;Custom Functions============================================= Func Process() If FileExists(GUICtrlRead($BrowseInput)) = 0 Then MsgBox(0, "My Movies Backup", "The destination directory specified is invalid or does not exist.") Return 1 EndIf ;Cleanup existing jobs If $BackupRow > 0 Then RunWait(@ComSpec & ' /c schtasks.exe /DELETE /F /TN "MyMovies Backup Job"', @SystemDir, @SW_HIDE) If $CleanupRow > 0 Then RunWait(@ComSpec & ' /c schtasks.exe /DELETE /F /TN "MyMovies Backup Cleanup"', @SystemDir, @SW_HIDE) Sleep(100) ;Verify deleted jobs if needed $TaskQuery = QueryJobs() If $BackupRow > 0 OR $CleanupRow > 0 Then MsgBox(0, "My Movies Backup", "Error cleaning up existing jobs." & @CR & "Please try again.") Return 1 EndIf ;Read Backup Scheme $BackupSchemeTXT = GUICtrlRead($BackupScheme) If $BackupSchemeTXT = "On Idle" Then $BackupSchemeTXT = "ONIDLE" If $BackupSchemeTXT = "On Startup" Then $BackupSchemeTXT = "onstart" If $BackupSchemeTXT = "On Logon" Then $BackupSchemeTXT = "ONLOGON" ;Create variable for backup parameters ;Set Backup Scheme $BackupParms = "/SC " & $BackupSchemeTXT & " " ;Set Idle Time If GUICtrlRead($IdleTime) > 0 Then $BackupParms = $BackupParms & "/I " & GUICtrlRead($IdleTime) & " " ;Set Start Time $StartTime = GUICtrlRead($Hours) & ":" If GUICtrlRead($AMPM) = "PM" Then $StartTime = GUICtrlRead($Hours) + 12 & ":" $StartTime = $StartTime & GUICtrlRead($Minutes) & ":" $StartTime = $StartTime & "00" If $BackupSchemeTXT <> "ONIDLE" Then $BackupParms = $BackupParms & "/ST " & $StartTime & " " ;Set Hourly Specific Parms If $BackupSchemeTXT = "Hourly" Then $BackupParms = $BackupParms & "/MO " & GUICtrlRead($Hourly) EndIf ;No additional parms needed for Daily ;Set Weekly Specific Parms If $BackupSchemeTXT = "Weekly" Then If GUICtrlRead($Sunday) = $GUI_UNCHECKED AND GUICtrlRead($Monday) = $GUI_UNCHECKED AND GUICtrlRead($Tuesday) = $GUI_UNCHECKED AND GUICtrlRead($Wednesday) = $GUI_UNCHECKED AND GUICtrlRead($Thursday) = $GUI_UNCHECKED AND GUICtrlRead($Friday) = $GUI_UNCHECKED AND GUICtrlRead($Saturday) = $GUI_UNCHECKED Then MsgBox(0, "My Movies Backup", "You must select a day of the week for this backup scheme.") Return 1 EndIf If GUICtrlRead($Sunday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "SUN " If GUICtrlRead($Monday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "MON " If GUICtrlRead($Tuesday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "TUE " If GUICtrlRead($Wednesday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "WED " If GUICtrlRead($Thursday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "THU " If GUICtrlRead($Friday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "FRI " If GUICtrlRead($Saturday) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/D " & "SAT " EndIf ;Set Monthly Specific Parms If $BackupSchemeTXT = "Monthly" Then If GUICtrlRead($MonthlySched1) = $GUI_CHECKED Then ;MonthlyMode/MonthlyDay If GUICtrlRead($MonthlyMode) = "" OR GUICtrlRead($MonthlyDay) = "" Then MsgBox(0, "My Movies Backup", "Invalid parameters specified in the Monthly section.") Return 1 EndIf $BackupParms = $BackupParms & "/MO " & GUICtrlRead($MonthlyMode) & " /D " & StringLeft(GUICtrlRead($MonthlyDay), 3) & " " EndIf If GUICtrlRead($FirstDay) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/MO FIRST " If GUICtrlRead($LastDay) = $GUI_CHECKED Then $BackupParms = $BackupParms & "/MO LAST " If GUICtrlRead($MonthlyDateCB) = $GUI_CHECKED Then EndIf EndIf If $BackupSchemeTXT = "onstart" OR $BackupSchemeTXT = "ONLOGON" Then $BackupParms = "/SC " & $BackupSchemeTXT MsgBox(0,"BackupParms", $BackupParms) EndFunc Func QueryJobs() Local $line Local $line2 Local $foo = Run(@ComSpec & ' /c schtasks.exe /query /FO csv /V', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While ProcessExists($foo) $line = StdoutRead($foo, True) $line2 = StderrRead($foo, True) WEnd For $i = 1 To 3 If StringLeft($line, 1) = @CR OR StringLeft($line, 1) = @CRLF OR StringLeft($line, 1) = @LF Then $line = StringTrimLeft($line, 1) If StringLeft($line2, 1) = @CR OR StringLeft($line2, 1) = @CRLF OR StringLeft($line2, 1) = @LF Then $line2 = StringTrimLeft($line2, 1) If StringRight($line, 1) = @CR OR StringRight($line, 1) = @CRLF OR StringRight($line, 1) = @LF Then $line = StringTrimRight($line, 1) If StringRight($line2,1) = @CR OR StringRight($line2,1) = @CRLF OR StringRight($line2,1) = @LF Then $line2 = StringTrimRight($line2,1) Next $line = _CSVToArray(0, ",", $line) For $i = 1 To Ubound($line) - 1 If $line[$i][1] = "MyMovies Backup Job" Then $BackupRow = $i If $line[$i][1] = "MyMovies Backup Cleanup" Then $CleanupRow = $i Next Return $line EndFunc ;====================================================================== Func BackupScheme() GUICtrlSetState($BrowseButton, $GUI_ENABLE) GUICtrlSetState($CreateJob, $GUI_ENABLE) $1 = GUICtrlRead($BackupScheme) If $1 = "Hourly" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(1) ToggleIdleTime(1) ToggleHourly(1) ToggleWeekly(0) ToggleMonthly(0) ElseIf $1 = "Daily" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(1) ToggleIdleTime(1) ToggleHourly(0) ToggleWeekly(0) ToggleMonthly(0) ElseIf $1 = "Weekly" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(1) ToggleIdleTime(1) ToggleHourly(0) ToggleWeekly(1) ToggleMonthly(0) ElseIf $1 = "Monthly" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(1) ToggleIdleTime(1) ToggleHourly(0) ToggleWeekly(0) ToggleMonthly(1) ElseIf $1 = "On Startup" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(0) ToggleIdleTime(0) ToggleHourly(0) ToggleWeekly(0) ToggleMonthly(0) ElseIf $1 = "On Logon" Then GUICtrlSetData($IdleGroup, " Idle Time (Optional) ") GUICtrlSetData($IdleTime, 0) ToggleStartTime(0) ToggleIdleTime(0) ToggleHourly(0) ToggleWeekly(0) ToggleMonthly(0) ElseIf $1 = "On Idle" Then GUICtrlSetData($IdleGroup, " Idle Time (Required) ") GUICtrlSetData($IdleTime, "") ToggleStartTime(0) ToggleIdleTime(1) ToggleHourly(0) ToggleWeekly(0) ToggleMonthly(0) GUICtrlSetState($IdleTime, $GUI_FOCUS) EndIf Return 0 EndFunc Func ToggleStartTime($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($Hours, $sStatus) GUICtrlSetState($Minutes, $sStatus) GUICtrlSetState($AMPM, $sStatus) Return 0 EndFunc Func ToggleIdleTime($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($IdleTime, $sStatus) Return 0 EndFunc Func ToggleHourly($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($Hourly, $sStatus) Return 0 EndFunc Func ToggleWeekly($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($Sunday, $GUI_UNCHECKED) GUICtrlSetState($Monday, $GUI_UNCHECKED) GUICtrlSetState($Tuesday, $GUI_UNCHECKED) GUICtrlSetState($Wednesday, $GUI_UNCHECKED) GUICtrlSetState($Thursday, $GUI_UNCHECKED) GUICtrlSetState($Friday, $GUI_UNCHECKED) GUICtrlSetState($Saturday, $GUI_UNCHECKED) GUICtrlSetState($Sunday, $sStatus) GUICtrlSetState($Monday, $sStatus) GUICtrlSetState($Tuesday, $sStatus) GUICtrlSetState($Wednesday, $sStatus) GUICtrlSetState($Thursday, $sStatus) GUICtrlSetState($Friday, $sStatus) GUICtrlSetState($Saturday, $sStatus) Return 0 EndFunc Func ToggleMonthly($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($MonthlySched1, $sStatus) GUICtrlSetState($MonthlySched1, $GUI_UNCHECKED) GUICtrlSetState($FirstDay, $sStatus) GUICtrlSetState($FirstDay, $GUI_UNCHECKED) GUICtrlSetState($LastDay, $sStatus) GUICtrlSetState($LastDay, $GUI_UNCHECKED) GUICtrlSetState($MonthlyMode, $sStatus) GUICtrlSetState($MonthlyDay, $sStatus) GUICtrlSetState($MonthlyDate, $sStatus) GUICtrlSetState($MonthlyDateCB, $sStatus) GUICtrlSetState($MonthlyDateCB, $GUI_UNCHECKED) Return 0 EndFunc Func ToggleArchive($sStatus) If $sStatus <> 0 AND $sStatus <> 1 Then Return 1 If $sStatus = 0 Then $sStatus = $GUI_DISABLE If $sStatus = 1 Then $sStatus = $GUI_ENABLE GUICtrlSetState($ArchiveLimitCheckbox, $GUI_UNCHECKED) GUICtrlSetState($ArchiveDirInput, "") GUICtrlSetState($ArchiveLimitInput, 0) GUICtrlSetState($ArchiveDirInput, $sStatus) GUICtrlSetState($ArchiveScheme, $sStatus) GUICtrlSetState($ArchiveLimitCheckbox, $sStatus) GUICtrlSetState($ArchiveLimitInput, $sStatus) GUICtrlSetState($ArchiveDirInput, $sStatus) GUICtrlSetState($ArchiveBrowse, $sStatus) EndFunc -Kenny "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
ken82m Posted November 18, 2008 Author Share Posted November 18, 2008 When I edited thescript that created the form it added a second GUISetState that was causing the confusion "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now