AutoDEV Posted March 30, 2024 Posted March 30, 2024 Hello i have this : expandcollapse popupLocal $iResult = _MsgBox_CountDown("My GUI", "Wait pelase ", 5) If $iResult = $IDOK Then ;ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : OK Pressed" & @CRLF) ElseIf $iResult = $IDTIMEOUT Then ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : Timeout" & @CRLF) ;Else ;ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : Cancel Pressed" & @CRLF) EndIf ; #FUNCTION# ================================================================================ ; Name...........: MsgBox_CountDown ; Description ...: MsgBox with visual CountDown ; Syntax.........: MsgBox_CountDown($sTitle, $sMessage, $iTimeOut = 30, $hWnd = 0) ; Parameters ....: $sTitle - The title of the message box ; $sMessage - The text of the message box ; $iTimeOut - Optional - Timeout in seconds ; $hWnd - Optional - The window handle to use as the parent for this dialog. ; Return values .: Success - Following return codes: ; OK : $IDOK (1) ; Timeout : $IDTIMEOUT (-1) ; Cancel : $IDCANCEL (2) ; Failure - Returns @Error: ; |1 - Erroneous Timout value, should be higher than 0 ; Author ........: GreenCan ; Modified.......: ; Remarks .......: Not meant as a replacement of MsgBox ; Related .......: ; Link ..........: ; Example .......: No ; =========================================================================================== Func _MsgBox_CountDown($sTitle, $sMessage, $iTimeOut = 30, $hWnd = 0) If $iTimeOut < 0 Then Return SetError(1, 0, 0) Local $hMsgBoxCtDwn, $hButtonOK, $hButtonCancel, $Sec = @SEC, $sMsg, $iMsg Local $iWidth = 300, $iHeight = 200 $hMsgBoxCtDwn = GUICreate($sTitle, $iWidth, 100, -1, -1, $WS_DLGFRAME, -1, $hWnd) $sMsg = GUICtrlCreateLabel($sMessage & " " & $iTimeOut & " sec", 0, 20, $iWidth, 28, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $hButtonOK = GUICtrlCreateButton("OK", ($iWidth/2) - 85, $iHeight - 50, 80, 20, BitOR($BS_CENTER, $BS_DEFPUSHBUTTON)) $hButtonCancel = GUICtrlCreateButton("Cancel", ($iWidth/2) + 5, $iHeight - 50, 80, 20, $BS_CENTER) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $hButtonOK GUIDelete($hMsgBoxCtDwn) Return $IDOK Case $iMsg = $hButtonCancel Or $iMsg = $GUI_EVENT_CLOSE GUIDelete($hMsgBoxCtDwn) Return $IDCANCEL Case $iTimeOut = 0 GUIDelete($hMsgBoxCtDwn) Return $IDTIMEOUT EndSelect If @SEC <> $Sec Then $Sec = @SEC $iTimeOut -= 1 GUICtrlSetData($sMsg, $sMessage & " " & $iTimeOut & " sec") EndIf WEnd EndFunc ;==>MsgBox_CountDown I have one line. I want a time seconde in bottom "wait". I not found on google. TY
Andreik Posted March 30, 2024 Posted March 30, 2024 Like this? expandcollapse popup#include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Local $iResult = _MsgBox_CountDown("My GUI", "Wait pelase ", 5) If $iResult = $IDOK Then ;ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : OK Pressed" & @CRLF) ElseIf $iResult = $IDTIMEOUT Then ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : Timeout" & @CRLF) ;Else ;ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : Cancel Pressed" & @CRLF) EndIf ; #FUNCTION# ================================================================================ ; Name...........: MsgBox_CountDown ; Description ...: MsgBox with visual CountDown ; Syntax.........: MsgBox_CountDown($sTitle, $sMessage, $iTimeOut = 30, $hWnd = 0) ; Parameters ....: $sTitle - The title of the message box ; $sMessage - The text of the message box ; $iTimeOut - Optional - Timeout in seconds ; $hWnd - Optional - The window handle to use as the parent for this dialog. ; Return values .: Success - Following return codes: ; OK : $IDOK (1) ; Timeout : $IDTIMEOUT (-1) ; Cancel : $IDCANCEL (2) ; Failure - Returns @Error: ; |1 - Erroneous Timout value, should be higher than 0 ; Author ........: GreenCan ; Modified.......: ; Remarks .......: Not meant as a replacement of MsgBox ; Related .......: ; Link ..........: ; Example .......: No ; =========================================================================================== Func _MsgBox_CountDown($sTitle, $sMessage, $iTimeOut = 30, $hWnd = 0) If $iTimeOut < 0 Then Return SetError(1, 0, 0) Local $hMsgBoxCtDwn, $hButtonOK, $hButtonCancel, $Sec = @SEC, $sMsg, $iMsg Local $iWidth = 300, $iHeight = 200 $hMsgBoxCtDwn = GUICreate($sTitle, $iWidth, 120, -1, -1, $WS_DLGFRAME, -1, $hWnd) $sMsg = GUICtrlCreateLabel($sMessage & @CRLF & $iTimeOut & " sec", 0, 20, $iWidth, 70, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $hButtonOK = GUICtrlCreateButton("OK", ($iWidth/2) - 85, $iHeight - 50, 80, 20, BitOR($BS_CENTER, $BS_DEFPUSHBUTTON)) $hButtonCancel = GUICtrlCreateButton("Cancel", ($iWidth/2) + 5, $iHeight - 50, 80, 20, $BS_CENTER) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Select Case $iMsg = $hButtonOK GUIDelete($hMsgBoxCtDwn) Return $IDOK Case $iMsg = $hButtonCancel Or $iMsg = $GUI_EVENT_CLOSE GUIDelete($hMsgBoxCtDwn) Return $IDCANCEL Case $iTimeOut = 0 GUIDelete($hMsgBoxCtDwn) Return $IDTIMEOUT EndSelect If @SEC <> $Sec Then $Sec = @SEC $iTimeOut -= 1 GUICtrlSetData($sMsg, $sMessage & @CRLF & $iTimeOut & " sec") EndIf WEnd EndFunc ;==>MsgBox_CountDown
AutoDEV Posted March 30, 2024 Author Posted March 30, 2024 Thank you. Working, i have make like you but i have forgot to add #include <ButtonConstants.au3>. For Can you help me to stop a program when searching image is searching ? Very big thank you
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