Search the Community
Showing results for tags 'longish sleep'.
-
Hello AutoIt fans, could anyone help me to get back on track please? So I managed to interrupt my function by pressing "Func two" button. But how can I terminate fuction by pressing "X" in GUI ? How can I assign "X" button to "Func two" if that's possible. Regards Ruslanas402 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $fInterrupt = 0 $hGUI = GUICreate("Test", 500, 500) $hButton_1 = GUICtrlCreateButton("Func One", 10, 10, 80, 30) $hButton_2 = GUICtrlCreateButton("Func Two", 10, 50, 80, 30) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $hButton_2 Then $fInterrupt = 1 Return $GUI_RUNDEFMSG EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 _Func_1() Case $hButton_2 Exit EndSwitch WEnd Func _Func_1() $fInterrupt = 0 For $i = 1 To 10 ConsoleWrite("-Func 1 Running" & @CRLF) If _Interrupt_Sleep(5000) Then Switch $fInterrupt Case 1 ConsoleWrite("!Func 1 interrrupted" & @CRLF) EndSwitch Return EndIf Next ConsoleWrite(">Func 1 Ended" & @CRLF) EndFunc Func _Interrupt_Sleep($iDelay) Local $iBegin = TimerInit() Do Sleep(10) If $fInterrupt Then Return True EndIf Until TimerDiff($iBegin) > $iDelay Return False EndFunc
- 5 replies
-
- longish sleep
- abort
-
(and 2 more)
Tagged with: