ByteRipper Posted October 18, 2006 Share Posted October 18, 2006 (edited) is it possible exit the loop by clicking on one of the buttons if i call the function _MsgBox from below while-wend? ok to restart the computer without waiting on the countdown. cancel to stop the countdown and exit the script. expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $LblTxt, $BtnOK $FormOptions = GUICreate("Optionen", 640, 480, -1, -1, BitOr($WS_POPUP,$WS_DLGFRAME, $DS_SETFOREGROUND)) $Btn1 = GUICtrlCreateButton("test", 80, 55, 75, 25, 0) GUICtrlSetOnEvent(-1, "_Start") GUISetState(@SW_SHOW, $FormOptions) While 1 Sleep(5) WEnd Func _MsgBox($MsgTitle, $MsgBtn1, $MsgBtn2, $MsgIconFile, $MsgIconNo, $MsgText) $FormCountDownMsG = GUICreate($MsgTitle, 300, 110, -1, -1, $WS_DLGFRAME) $BtnOK = GUICtrlCreateButton($MsgBtn1, 80, 55, 75, 25, 0) GUICtrlSetOnEvent(-1, "_MsgBtnOK") $BtnCancel = GUICtrlCreateButton($MsgBtn2, 190, 55, 75, 25, 0) GUICtrlSetOnEvent(-1, "_Exit") $Icon = GUICtrlCreateIcon($MsgIconFile, $MsgIconNo, 16, 16, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP)) $LblTxt = GUICtrlCreateLabel($MsgText, 72, 16, 210, 25) GUISetState(@SW_SHOW, $FormCountDownMsG) EndFunc Func _MsgBtnOK() MsgBox(16,"Shutdown","Shutdown 2") EndFunc Func _Exit() Exit EndFunc Func _MsgBoxCountDown() For $i = 10 To 1 Step -1 GUICtrlSetData($LblTxt, "Computer will restart in "&$i&" seconds.") GUICtrlSetData ($BtnOK, "OK ( "&$i&" )" ) sleep(1000) If $i = 1 Then Return -1 EndIf Next EndFunc Func _Start() GUISetState(@SW_HIDE, $FormOptions) _MsgBox("Information", "OK", "Cancel", "Shell32.dll", 221, "") $MsgCounterEnd = _MsgBoxCountDown() If $MsgCounterEnd = -1 Then MsgBox(16,"Shutdown","Shutdown 2") Exit EndIf EndFunc Edited October 18, 2006 by ByteRipper Link to comment Share on other sites More sharing options...
NELyon Posted October 18, 2006 Share Posted October 18, 2006 ... $msg = GUIGetMsg() If $msg = $ExitButton then ExitLoop ... Link to comment Share on other sites More sharing options...
ByteRipper Posted October 18, 2006 Author Share Posted October 18, 2006 well my first example habens to work as it suppose to. but in my script it did'nt. so i changed the code in my first post according to the code in my script. i think i found the problem. when i have 2 windows and call that msgbox from the first one, set state of 1st window to hide it's not working any more. question is why. any suggestion. Link to comment Share on other sites More sharing options...
ByteRipper Posted October 20, 2006 Author Share Posted October 20, 2006 found a solution, AdlibEnable("_MsgBoxCountDown"). still a question left, where to put AdlibDisable() best. Func _Start() GUISetState(@SW_HIDE, $FormOptions) _MsgBox("Information", "OK", "Cancel", "Shell32.dll", 221, "") $MsgCounterEnd = AdlibEnable("_MsgBoxCountDown") If $MsgCounterEnd = -1 Then MsgBox(16,"Shutdown","Shutdown 2") ;Exit EndIf EndFunc 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