Jump to content
Sign in to follow this  
luis713

interrupt a function

Recommended Posts

luis713

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

 

Share this post


Link to post
Share on other sites
luis713

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()")

 

Share this post


Link to post
Share on other sites
JLogan3o13

So can you please explain just what you're trying to do? What is the significance for the EndGame function - what game?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
luis713

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

Share this post


Link to post
Share on other sites
JLogan3o13

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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.