HockeyFan Posted November 3, 2006 Share Posted November 3, 2006 (edited) This is probably something simple and I'm just not seeing it, but why won't my script exit? The function call works fine, but I just can't get the darn thing to quit! :"> expandcollapse popup; Script Start #include <GUIConstants.au3> #Include <Misc.au3> AutoItSetOption("TrayIconHide", 0) ;0 = show icon (default), 1 = hide icon. Break(1) ;1 = Break is enabled (user can quit) (default), 0 = Break is disabled (user cannot quit). Opt("GUIOnEventMode", 1) ;Opt("OnExitFunc", "OnAutoItExit") $font = "Arial Bold" ;GUI Message Screen Text $GuiText1 = "For software installation tracking purposes only..." $GuiText2 = "So that the IT Department will know which computers have been upgraded," & @CR & "please type your name...(the person who uses this computer)...in the box below and then press the <ENTER> key:" $GuiText3 = "Use this format:" & @CR & "First_Name Last_Name (ie Joe Smith)" $GuiText4 = "Click the OK button to begin installation." ;GUI Message Screen Creation $GuiWindow = GUICreate(" User Information", 620, 360, -1, -1, -1, $WS_EX_TOOLWINDOW) $Text1 = GUICtrlCreateLabel ($GuiText1, 20, 10, 580, 22) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ($Text1, 0xff0000) $Text2 = GUICtrlCreateLabel ($GuiText2, 20, 50, 580, 164) GUICtrlSetFont(-1, 12, 400, 0, $font) ;GUICtrlSetColor ($Text2, 0xff0000) $Text3 = GUICtrlCreateLabel ($GuiText3, 20, 130, 580, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ($Text3, 0x0000FF) $UserInputBox = GUICtrlCreateInput ("", 20, 180, 320, 25) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ( $UserInputBox, 0xff0000) GUICtrlSetState(-1, $GUI_FOCUS) $Text4 = GUICtrlCreateLabel ($GuiText4, 20, 220, 380, 20) GUICtrlSetFont(-1, 12, 400, 0, $font) $OKButton = GUICtrlCreateButton ("OK", 265, 280, 80, 50) GUICtrlSetOnEvent($OKButton, "OKButton") GUICtrlSetFont(-1, 12, 400, 0, $font) GUISetState() ;Hide Text until user hits the enter key GUICtrlSetState($Text4, $GUI_HIDE) ;Disable the OK button until the User inputs data ControlDisable(" User Information", "OK", 8) ;GUICtrlSetState($OKbutton, $GUI_HIDE) $dll = DllOpen("C:\WINDOWS\system32\user32.dll") $TypeName = GUICtrlRead($UserInputBox) Do Sleep(100) $TypeName = GUICtrlRead($UserInputBox) Until $TypeName <> "" Do Sleep(100) Until _IsPressed("0D", $dll) $TypeName = GUICtrlRead($UserInputBox) GUICtrlSetState($Text4, $GUI_SHOW) ControlEnable(" User Information", "OK", 8) ControlGetFocus ($UserInputBox) ;GUICtrlSetState($OKButton, $GUI_SHOW) DllClose($dll) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Do some stuff with files on workstation.;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 $msg = GUIGetMsg() WEnd Exit Func OKButton() MsgBox(0, "", "The OK button was pressed") ;for testing only. EndFunc Edited November 3, 2006 by HockeyFan Link to comment Share on other sites More sharing options...
_Kurt Posted November 3, 2006 Share Posted November 3, 2006 (edited) I think I know what you're missing: While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Edited November 3, 2006 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
Valuater Posted November 3, 2006 Share Posted November 3, 2006 maybe GUISetOnEvent($GUI_EVENT_CLOSE, "MyCloseFunction") Func MyCloseFunction() Exit EndFunc 8) Link to comment Share on other sites More sharing options...
_Kurt Posted November 3, 2006 Share Posted November 3, 2006 Either way works Try 'em both and see which one you prefer Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
Valuater Posted November 3, 2006 Share Posted November 3, 2006 I think I know what you're missing: While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd that does not work with on-event-mode nor does this ( from above ) ;Do some stuff with files on workstation.;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 $msg = GUIGetMsg() WEnd 8) Link to comment Share on other sites More sharing options...
HockeyFan Posted November 3, 2006 Author Share Posted November 3, 2006 maybe expandcollapse popupGUISetOnEvent($GUI_EVENT_CLOSE, "MyCloseFunction") Func MyCloseFunction() Exit EndFuncoÝ÷ ÛÏêº^U©nj׫"¯zëw*.®Ë ë-ìnëHßÙ¬¶)e`zÛbay׬·ë.Õ¡j×¥±ç(ºWHm颲ȧé캷z·¢²l®¥ÖyÛ®*mjëh×6 ; Script Start #include <GUIConstants.au3> #Include <Misc.au3> AutoItSetOption("TrayIconHide", 0) ;0 = show icon (default), 1 = hide icon. Break(1) ;1 = Break is enabled (user can quit) (default), 0 = Break is disabled (user cannot quit). Opt("GUIOnEventMode", 1) ;Opt("OnExitFunc", "OnAutoItExit") $font = "Arial Bold" ;GUI Message Screen Text $GuiText1 = "For software installation tracking purposes only..." $GuiText2 = "So that the IT Department will know which computers have been upgraded," & @CR & "please type your name...(the person who uses this computer)...in the box below and then press the <ENTER> key:" $GuiText3 = "Use this format:" & @CR & "First_Name Last_Name (ie Joe Smith)" $GuiText4 = "Click the OK button to begin installation." ;GUI Message Screen Creation $GuiWindow = GUICreate(" User Information", 620, 360, -1, -1, -1, $WS_EX_TOOLWINDOW) $Text1 = GUICtrlCreateLabel ($GuiText1, 20, 10, 580, 22) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ($Text1, 0xff0000) $Text2 = GUICtrlCreateLabel ($GuiText2, 20, 50, 580, 164) GUICtrlSetFont(-1, 12, 400, 0, $font) ;GUICtrlSetColor ($Text2, 0xff0000) $Text3 = GUICtrlCreateLabel ($GuiText3, 20, 130, 580, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ($Text3, 0x0000FF) $UserInputBox = GUICtrlCreateInput ("", 20, 180, 320, 25) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor ( $UserInputBox, 0xff0000) GUICtrlSetState(-1, $GUI_FOCUS) $Text4 = GUICtrlCreateLabel ($GuiText4, 20, 220, 380, 20) GUICtrlSetFont(-1, 12, 400, 0, $font) $OKButton = GUICtrlCreateButton ("OK", 265, 280, 80, 50) ;GUICtrlSetOnEvent($OKButton, "OKButton") GUISetOnEvent($GUI_EVENT_CLOSE, "OKButton") GUICtrlSetFont(-1, 12, 400, 0, $font) GUISetState() ;Hide Text until user hits the enter key GUICtrlSetState($Text4, $GUI_HIDE) ;Disable the OK button until the User inputs data ControlDisable(" User Information", "OK", 8) ;GUICtrlSetState($OKbutton, $GUI_HIDE) $dll = DllOpen("C:\WINDOWS\system32\user32.dll") $TypeName = GUICtrlRead($UserInputBox) Do Sleep(100) $TypeName = GUICtrlRead($UserInputBox) Until $TypeName <> "" Do Sleep(100) Until _IsPressed("0D", $dll) $TypeName = GUICtrlRead($UserInputBox) GUICtrlSetState($Text4, $GUI_SHOW) ControlEnable(" User Information", "OK", 8) ControlGetFocus ($UserInputBox) ;GUICtrlSetState($OKButton, $GUI_SHOW) DllClose($dll) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Do some stuff with files on workstation.;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 $msg = GUIGetMsg() WEnd Exit Func OKButton() MsgBox(0, "", "The OK button was pressed"); for testing purposes Exit EndFunc Link to comment Share on other sites More sharing options...
Valuater Posted November 3, 2006 Share Posted November 3, 2006 I did not fix your over-all-direction... just the problem expandcollapse popup; Script Start #include <GUIConstants.au3> #Include <Misc.au3> AutoItSetOption("TrayIconHide", 0) ;0 = show icon (default), 1 = hide icon. Break(1) ;1 = Break is enabled (user can quit) (default), 0 = Break is disabled (user cannot quit). Opt("GUIOnEventMode", 1) ;Opt("OnExitFunc", "OnAutoItExit") $font = "Arial Bold" ;GUI Message Screen Text $GuiText1 = "For software installation tracking purposes only..." $GuiText2 = "So that the IT Department will know which computers have been upgraded," & @CR & "please type your name...(the person who uses this computer)...in the box below and then press the <ENTER> key:" $GuiText3 = "Use this format:" & @CR & "First_Name Last_Name (ie Joe Smith)" $GuiText4 = "Click the OK button to begin installation." ;GUI Message Screen Creation $GuiWindow = GUICreate(" User Information", 620, 360, -1, -1, -1, $WS_EX_TOOLWINDOW) $Text1 = GUICtrlCreateLabel($GuiText1, 20, 10, 580, 22) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor($Text1, 0xff0000) $Text2 = GUICtrlCreateLabel($GuiText2, 20, 50, 580, 164) GUICtrlSetFont(-1, 12, 400, 0, $font) ;GUICtrlSetColor ($Text2, 0xff0000) $Text3 = GUICtrlCreateLabel($GuiText3, 20, 130, 580, 50) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor($Text3, 0x0000FF) $UserInputBox = GUICtrlCreateInput("", 20, 180, 320, 25) GUICtrlSetFont(-1, 12, 400, 0, $font) GUICtrlSetColor($UserInputBox, 0xff0000) GUICtrlSetState(-1, $GUI_FOCUS) $Text4 = GUICtrlCreateLabel($GuiText4, 20, 220, 380, 20) GUICtrlSetFont(-1, 12, 400, 0, $font) $OKButton = GUICtrlCreateButton("OK", 265, 280, 80, 50) GUICtrlSetOnEvent($OKButton, "OKButton") GUICtrlSetFont(-1, 12, 400, 0, $font) GUISetOnEvent($GUI_EVENT_CLOSE, "OKButton") GUISetState() ;Hide Text until user hits the enter key GUICtrlSetState($Text4, $GUI_HIDE) ;Disable the OK button until the User inputs data ControlDisable(" User Information", "OK", 8) ;GUICtrlSetState($OKbutton, $GUI_HIDE) $dll = DllOpen("C:\WINDOWS\system32\user32.dll") $TypeName = GUICtrlRead($UserInputBox) Do Sleep(100) $TypeName = GUICtrlRead($UserInputBox) Until $TypeName <> "" ControlEnable(" User Information", "OK", 8) Do Sleep(100) Until _IsPressed("0D", $dll) $TypeName = GUICtrlRead($UserInputBox) GUICtrlSetState($Text4, $GUI_SHOW) ;ControlEnable(" User Information", "OK", 8) ControlGetFocus($UserInputBox) ;GUICtrlSetState($OKButton, $GUI_SHOW) DllClose($dll) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Do some stuff with files on workstation.;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; While 1 ;$msg = GUIGetMsg() Sleep(10) WEnd Exit Func OKButton() MsgBox(0, "", "The OK button was pressed"); for testing purposes Exit EndFunc ;==>OKButton 8) Link to comment Share on other sites More sharing options...
HockeyFan Posted November 3, 2006 Author Share Posted November 3, 2006 I did not fix your over-all-direction... just the problem Valuater, Thanks for the help...and sorry for the confusion. My "desired result" was getting the darn thing to exit when I clicked the OK button...that was the problem! With your corrections the script now does what I want...thank you! I guess my problem was with the $msg = GUIGetMsg() in the While/WEnd loop. Hmmmmm...I'll have to look at that. Thanks again for you help. 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