anhchangtk Posted October 10, 2009 Share Posted October 10, 2009 (edited) I'm want to use 2 loop to made 1 code auto close windows but the code know only 1 in 2 loop if loop 2 run all the button in loop 1 disabled This is my code #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $shutting = GUICreate("Shutdown", 217, 89, 192, 124) $shutdown = GUICtrlCreateButton("Shutdown Now", 8, 48, 99, 25) $cancel = GUICtrlCreateButton("Canclel", 128, 48, 75, 25) $report = GUICtrlCreateLabel("", 8, 16, 198, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() $i = 0 While $i <= 20 $s = 20-$i GUICtrlSetData ($report,"Windows will shutting down in " & $s & " second") $s = "" $i = $i+1 Sleep(1000) WEnd msgbox (0,"Report", "Done.......") exit If $nMsg = $cancel then Exit if $nMsg = $shutdown then msgbox (0,"Report", "Done.......") exit endif if $nMsg = $GUI_EVENT_CLOSE then exit WEnd Thanks everyone had read my topic Edited October 10, 2009 by anhchangtk Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 10, 2009 Moderators Share Posted October 10, 2009 anhchangtk,You actually need 3 loops: 1. Outer to keep looking for button presses.2. Middle to keep your timer running.3. Inner to wait for 1 sec between timer clicks AND keep looking for the Cancel button.#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $shutting = GUICreate("Shutdown", 217, 89, 192, 124) $shutdown = GUICtrlCreateButton("Shutdown Now", 8, 48, 99, 25) $cancel = GUICtrlCreateButton("Cancel", 128, 48, 75, 25) $report = GUICtrlCreateLabel("", 8, 16, 198, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Outer Switch GUIGetMsg() Case $shutdown $s = 20 While 1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Middle GUICtrlSetData($report, "Windows will shutting down in " & $s & " second") $iBegin = TimerInit() While TimerDiff($iBegin) < 1000 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Inner If GUIGetMsg() = $cancel Then GUICtrlSetData($report, "") ExitLoop 2 ; <<<<<<<<<<< Because we have 2 loops to exit EndIf ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Inner WEnd $s -= 1 If $s = 0 Then MsgBox(0, "Report", "Done.......") Exit EndIf WEnd ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Middle Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OuterAsk if anything is unclear.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...
Valuater Posted October 10, 2009 Share Posted October 10, 2009 Maybe... $iBegin = TimerInit() While 1 GUICtrlSetData($report, "Windows will shutting down in " & $s & " second") If GUIGetMsg() = $cancel Then GUICtrlSetData($report, "") ExitLoop EndIf If TimerDiff($iBegin) < 1000 Then $iBegin = TimerInit() $s -= 1 EndIf If $s = 0 Then MsgBox(0, "Report", "Done.......", 3) Exit EndIf WEnd 8) Link to comment Share on other sites More sharing options...
anhchangtk Posted October 10, 2009 Author Share Posted October 10, 2009 OK thanks Valuater and Melba23 @Valuater: code you run very well but i want when code run the $report will start count down and when click button windows will immediately shutdown the $report not will count down @Melba23: Your code me haven't used Link to comment Share on other sites More sharing options...
Valuater Posted October 10, 2009 Share Posted October 10, 2009 Sorry... change this If TimerDiff($iBegin) < 1000 Then to this If TimerDiff($iBegin) > 1000 Then Hope that helps 8) Link to comment Share on other sites More sharing options...
anhchangtk Posted October 11, 2009 Author Share Posted October 11, 2009 Sorry...change thisIf TimerDiff($iBegin) < 1000 Thento thisIf TimerDiff($iBegin) > 1000 ThenHope that helps8)OK that good thanks you very much 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