Jump to content

Search the Community

Showing results for tags 'interrupt'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


WWW


Interests

Found 3 results

  1. 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
  2. Let start with some examples: 1. (As seen in another topic: '?do=embed' frameborder='0' data-embedContent>> ). Script copied from that topic Interrupt function can be any hotkey/event/adlib/callback. If-check inside interrupted function/script ; HotKeySet, or any function that can cause script interrupt HotKeySet("{Delete}", "RemoveSelectedControl") ;... Dim $InfoAboutControls[4096] Global $HandleForCurrentControl ;... While 1 $msg = GuiGetMsg() ;.... ;---Code to process moving a control (drag-n-drop)--- ; If check in MAIN LOOP (interruptible function). If $HandleForCurrentControl > 0 Then;Make sure we have a valid control handle ; ***** oops user pressed Delete key and we get pre-empted ; ***** user removed the selected control. ; ***** Returning from the RemoveSelectedControl function and resuming here: GuiCtrlSetPos($InfoAboutControls[$HandleForCurrentControl], $newLeftPosition, $newTopPosition) EndIf WEnd Func RemoveSelectedControl() $HandleForCurrentControl = -1 EndFunc 2. If-check inside interrupt function Hotkey only. Flag is set right after if check. It's possible or not this function print twice or more? HotKeySet("{Delete}", "_TestHotkey") Func _TestHotkey() Static $bFlag = True If ($bFlag) Then ; ***** Right here, user pressed Delete key ; ***** bFlag is currently not set ; ***** And the script will execute this function twice or more times, instead of just once $bFlag = False ConsoleWrite("This should be printed only ONCE") EndIf EndFunc 3. Same as 2, but with global flag The question is: can I rely on if-checking with a flag, to ensure that my script doesn't do any strange things, as describe in the above examples?
  3. Hi guys, i have a script with a stop loop like this #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $fInterrupt = 0 $hGUI = GUICreate("Test", 100, 100) $hButton_1 = GUICtrlCreateButton("Func One", 10, 10, 80, 30) $hButton_2 = GUICtrlCreateButton("Func Two", 10, 50, 80, 30) GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 _Func_1() Case $hButton_2 _Func_2() EndSwitch WEnd Func _Func_1() $fInterrupt = 0 For $i = 1 To 20 ConsoleWrite("-Func 1 Running" & @CRLF) If $fInterrupt <> 0 Then ConsoleWrite("!Func 1 interrrupted by Func 2" & @CRLF) Return EndIf Sleep(100) Next ConsoleWrite(">Func 1 Ended" & @CRLF) EndFunc Func _Func_2() For $i = 1 To 3 ConsoleWrite("+Func 2 Running" & @CRLF) Sleep(100) Next ConsoleWrite(">Func 2 Ended" & @CRLF) EndFunc Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $hButton_2 Then $fInterrupt = 1 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND Work fine, but for GUI space problem i need to set it on the same button, one click for start ( label "Start" ) and then the second click for stop it ( label "Stop") I can make GUICtrlSetData for change the name, but i don't undestand how to stop the Func without using another button. Thanks
×
×
  • Create New...