dickep Posted July 30, 2008 Share Posted July 30, 2008 I know this has been asked somewhere but I can't seem to find it. I want to have a parent window with some selections. Then when the OK button is pressed, a child window will open and basically show a progress label of what is going on. THere should be a button for STOP and when that is pressed, the child window will stop and close. Then the main application should go to a function to complete the exiting "stuff". I have the code below, but when I press the STOP button it may or may not stop - mostly not. Can you tell me what I did wrong?? P.S. my code is never very elegant but sometimes I get it to work - properly that is. Thanks CODE ;=========================================================================== ; ; INCLUDE SECTION ; ;=========================================================================== #include <GUIConstants.au3> #include <CompInfo.au3> #include <Date.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;============================================================================ ; ; GLOBAL CONSTANTS AND VARIBLES ; ;=========================================================================== #region Global Variables and Constants #endregion Global Variables and Constants #region Variable declarations Dim $Processes, $i Dim $mDisplayHeight, $mDisplayWidth, $mDispCtrW, $mDispCtrH, $mMenuWidth, _ $mMenuHeight, $tTempMins, $tTempSecs Global $tTriggerTime Dim $tNewHour, $tNewMin, $tNewSec, $tOldHour, $tOldMin, $tOldSec dim $fLogFile1 = @DesktopDir & "\log.txt" dim $fLogFile1 = "c:\log.txt"; Dim $CB[42] Dim $fHandle1 Dim $mHeader[42] = ["Name","Command Line","Creation Class Name", _ "Creation Date","Description","CS Creation Class Name","CS Name", _ "Executable Path","Execution State","Handle","Handle Count", _ "Kernel Mode Time","Maximum Working Set Size","Minimum Working Set Size", _ "OS Creation Class Name","OS Name","Other Operation Count", _ "Other Transfer Count","Page Faults","Page File Usage","Parent Process ID", _ "Peak Page File Usage","Peak Virtual Size","Peak Working Set Size", _ "Priority","Private Page Count","Process ID","Quota Non Paged Pool Usage", _ "Quota Paged Pool Usage","Quota Peak Non Paged Pool Usage", _ "Quota Peak Paged Pool Usage","Read Operation Count","Read Transfer Count", _ "Session ID","Status","Thread Count","User Mode Time","Virtual Size", _ "Windows Version","Working Set Size","Write Operation Count", _ "Write Transfer Count"] Dim $CBchecked[42] Dim $fTemp, $mTemp, $a Dim $mWaitMsg = "Waiting.." Dim $iLimit = 5000000, $cnt dim $sOld, $sTotal, $sStringLen $mDisplayHeight = @DesktopHeight $mDisplayWidth = @DesktopWidth $mDispCtrW = Int($mDisplayWidth/2) $mDispCtrH = Int($mDisplayHeight/2) $mMenuWidth = 448 $mMenuHeight = 634 #endregion Variable declarations ;============================================================================ ; ; MAIN ; ;=========================================================================== ; Make the first user input GUI #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Manitoba Test Tool", $mMenuHeight, $mMenuWidth, ($mDispCtrW - (int(633/2))), ($mDispCtrH - (448/2))) GUISetFont(10, 700) $Button1 = GUICtrlCreateButton("OK", 192, 400, 75, 25, 0) $Button2 = GUICtrlCreateButton("Cancel", 352, 400, 75, 25, 0) GUISetState(@SW_SHOW, $Form1) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 $mWaitWin = GUICreate("Working....",300,100,45,75,BitOR($WS_CAPTION, $WS_SYSMENU),$WS_EX_MDICHILD,$Form1) $mWaitWinLabel1 = GUICtrlCreateLabel("",3,5,250,17) $mWaitWinButton1 = GUICtrlCreateButton("Stop", 175,75,40,20) ExitLoop case $button2 Exit EndSwitch WEnd GUISetState(@SW_HIDE, $Form1) GUISetState(@SW_SHOW, $mWaitWin) while 1 $b = 1 $c = "Waiting" while 1 ;for $a = 1 to $tTriggerTime Dim $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel() Case $nMsg = $mWaitWinButton1 GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel($ EndSelect $c = $c & "." GUICtrlSetData($mWaitWinLabel1, $c) sleep(900) $b += 1 sleep(100) if $b>15 Then ExitLoop EndIf WEnd GUICtrlSetData($mWaitWinLabel1,"Gathering Data") sleep(100) WEnd ;============================================================================================== ; ; FUNCTION AREA ; ;============================================================================================= Func _Cancel($r) FileClose($fLogFile1) MsgBox(0,"","Closing out logging files" & @CRLF & "B = " & $r) Exit EndFunc Link to comment Share on other sites More sharing options...
Linux Posted July 31, 2008 Share Posted July 31, 2008 I think those sleeps in the while 1 loop are making the gui response delay. Look at this solution, checking the gui at full speed and using timerdiff to update the label GUISetState(@SW_HIDE, $Form1) GUISetState(@SW_SHOW, $mWaitWin) $Timer = TimerInit() $TimerDiff = 1001 $b = 1 $c = "Waiting" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel() Case $mWaitWinButton1 GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel($B) EndSwitch If $TimerDiff > 1000 Then $Timer = TimerInit() $c = $c & "." GUICtrlSetData($mWaitWinLabel1, $c) $b += 1 If $b > 15 Then $b = 1 $c = "Waiting" GUICtrlSetData($mWaitWinLabel1, "Gathering Data") Sleep(500) EndIf EndIf $TimerDiff = TimerDiff($Timer) WEnd You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
dickep Posted August 1, 2008 Author Share Posted August 1, 2008 Thanks. I used this and the parent window closes properly, but whent I press the STOP button on the child, control does not go back to parent window, even though it opens and looks good. What am I missing? GUI stuff confuses me. Ep I think those sleeps in the while 1 loop are making the gui response delay. Look at this solution, checking the gui at full speed and using timerdiff to update the label GUISetState(@SW_HIDE, $Form1) GUISetState(@SW_SHOW, $mWaitWin) $Timer = TimerInit() $TimerDiff = 1001 $b = 1 $c = "Waiting" While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel() Case $mWaitWinButton1 GUISetState(@SW_ENABLE, $Form1) GUIDelete($mWaitWin) _Cancel($B) EndSwitch If $TimerDiff > 1000 Then $Timer = TimerInit() $c = $c & "." GUICtrlSetData($mWaitWinLabel1, $c) $b += 1 If $b > 15 Then $b = 1 $c = "Waiting" GUICtrlSetData($mWaitWinLabel1, "Gathering Data") Sleep(500) EndIf EndIf $TimerDiff = TimerDiff($Timer) WEnd 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