Jump to content

Recommended Posts

Posted

Hi, is there a way to interrupt a function? when we run sleep and we press a button it doesn't interrupts the function, can somebody explain to me how to do it? I have a code that runs in automatic and want to stop it with a button, like a start and end button

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $interrupt = GUICtrlCreateButton("Interrupt function", 300, 370, 95, 25)
    Local $idOK = GUICtrlCreateButton("Run function", 200, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $interrupt
               MsgBox(0, "", "Function interruped")

            Case $idOk
               _Run()

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
 EndFunc   ;==>Example

Func _Run()
   Sleep(10000)
EndFunc

 

  • Moderators
Posted

@luis713 We have a great Wiki that answers a lot of common questions such as this:

https://www.autoitscript.com/wiki/Interrupting_a_running_function

You might give it a whirl.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

I have read it before but I don't understand, could you explain me how to do it? Do I have to use something like this? If yes, where do i have to insert it in my code?

Opt("GUIOnEventMode", 1)
GUISetOnEvent($EndButton, "EndGame()")

 

Posted

Oks, I have a game (bingo) that can displays words in automatic mode or manual mode, when I start it in automatic I can't stop it because is in loop and I need a button to stop it in case of be necessary, could you explain to me how to do it? i really read that link before but is difficult for me

  • Moderators
Posted

Apparently during your time here you've never bothered to look at our forum rules. I suggest you do so now before posting again, specifically the section on game automation, and you will see why this thread has been locked. You will receive no help on this subject.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...