amin84 Posted September 18, 2010 Share Posted September 18, 2010 Hi, I've made a multi GUI script. The first GUI has a bunch of checkmarks with a button. When you press the button, it will check what is selected and it will run the second GUI which will be used to copy files depending on what was selected in the first GUI. Now the first GUI functions properly but the controls (close button) on the second one won't respond to anything. Does anybody know what I'm doing wrong? expandcollapse popup#include <ButtonConstants.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $mainWin, $copyWin, $officeCbox, $itunesCbox, $norton360Cbox, $nortonIS, $pureCbox, $winXp01Cbox, $winXp02Cbox, $winXp03Cbox, $startBtn, $numberOfFiles, $tasks = 0 _mainWin() Func _mainWin() $mainWin = GUICreate("Test Copy", 266, 138) GUISetOnEvent($GUI_EVENT_CLOSE, "_onClose") $officeCbox = GUICtrlCreateCheckbox("Office 2010", 8, 8, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $itunesCbox = GUICtrlCreateCheckbox("iTunes", 8, 24, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $norton360Cbox = GUICtrlCreateCheckbox("Norton 360", 8, 40, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $nortonIS = GUICtrlCreateCheckbox("Norton Internet S", 8, 56, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $pureCbox = GUICtrlCreateCheckbox("Kaspersky Pure", 136, 8, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $winXp01Cbox = GUICtrlCreateCheckbox("Win XP 01", 136, 24, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $winXp02Cbox = GUICtrlCreateCheckbox("Win XP 02", 136, 40, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $winXp03Cbox = GUICtrlCreateCheckbox("Win XP 03", 136, 56, 121, 17) GUICtrlSetOnEvent(-1, "_onBtn") $startBtn = GUICtrlCreateButton("Start Test Copy", 8, 80, 249, 49, $WS_GROUP) GUICtrlSetOnEvent(-1, "_onBtn") GUISetState() While 1 Sleep(10) WEnd EndFunc Func _copyWin() $copyWin = GUICreate("QuickTweak: Copying... ", 370, 97) GUISetOnEvent($GUI_EVENT_CLOSE, "_onClose") $infoLbl = GUICtrlCreateLabel("Copying Office..."&@LF&'Please Wait...', 8, 5, 360, 54, $SS_CENTER) GUICtrlSetFont(-1, 14, 400, 0, "Tahoma") $progressBar = GUICtrlCreateProgress(8, 55, 353, 33) GUISetState() Sleep(1000) GUICtrlSetData($progressBar, 10) ;finished copying first file Sleep(1000) GUICtrlSetData($progressBar, 20) ;finished copying 2nd file Sleep(1000) GUICtrlSetData($progressBar, 50) ;finished copying 3rd file Sleep(1000) GUICtrlSetData($progressBar, 100) ;finished copying 4th file Sleep(1000) GUICtrlSetData($infoLbl, "Please Wait...") Sleep(1000) Exit EndFunc Func _onClose() Switch @GUI_WinHandle Case $mainWin Exit Case $copyWin Exit ;~ $confirmExit = MsgBox(8228,"Oops!","Are you sure you want to delete all the copied files and exit the program?") ;~ If $confirmExit = 6 Then ;~ GUISetState(@SW_HIDE, $confirmExit) ;~ GUISetState(@SW_HIDE, $copyWin) ;~ MsgBox(0, "Done", "All files deleted. Program will exit now.") ;~ Exit ;~ EndIf EndSwitch EndFunc Func _onBtn() Switch @GUI_CTRLID Case $startBtn If GUICtrlRead($officeCbox) = 1 Then $tasks &= "01" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($itunesCbox) = 1 Then $tasks &= "02" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($norton360Cbox) = 1 Then $tasks &= "03" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($nortonIS) = 1 Then $tasks &= "04" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($pureCbox) = 1 Then $tasks &= "05" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($winXp01Cbox) = 1 Then $tasks &= "06" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($winXp02Cbox) = 1 Then $tasks &= "07" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If GUICtrlRead($winXp03Cbox) = 1 Then $tasks &= "08" & @LF $numberOfFiles = $numberOfFiles + 1 EndIf If $tasks = "" Then MsgBox(8240, 'Oops!', "Nothing selected!") Else $proceed = MsgBox(36,'Proceed...', 'Are you sure?') GUISetState(@SW_HIDE, $mainWin) _copyWin() EndIf EndSwitch EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 18, 2010 Moderators Share Posted September 18, 2010 leomoon,The [X] button on your second GUI is working fine. Remember that AutoIt waits until a function is finished before actioning the next in the queue - so you must wait for _copyWin() to end before the _onClose() function called by pressing the [X] is run (which in fact it never is as you exit directly from _copyWin ).Take a look at the Managing Multiple GUIs and Interrupting a running function tutorials in the Wiki for more information. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
amin84 Posted September 18, 2010 Author Share Posted September 18, 2010 Oo. Thanks. Yes the progress bar will exit when it's done (the fake) copying. The reason for the close button is for the user to interrupt it. Thanks for the link. I'll read the Interrupting a running function and post the modified script if everything goes well. 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