Jump to content

Recommended Posts

Posted

I have a script on a OnEvent GUI that automates a website and it has a bunch of ieloadwaits, sleeps, loops.... and i would like to terminate that main function script with a press of a gui button. So im wondering if there is a function that terminates executing of another function no matter if it is currently in sleep, loop... or any other function that halts code. Hope you understand. Help much appreciated. Thanks.

Posted

I think hotkeyset is what you are looking for. If not, try adlibenable to check to see if a button is pressed while the rest of the script executes.

Posted (edited)

Yeah hotkey does activate the function bound to it even if the rest of the script is in "halt" like sleep, loop.... But i still need a command to stop that main function executing. Ive been trying this, but it does nothing. And AdlibEnable also just calls a function, but every x time...

HotKeySet("{F9}", "terminate")

mainscript....

Func terminate()
    Return 0
    EndFunc
Edited by darkmaster071
Posted (edited)

Yeah hotkey does activate the function bound to it even if the rest of the script is in "halt" like sleep, loop.... But i still need a command to stop that main function executing. Ive been trying this, but it does nothing. And AdlibEnable also just calls a function, but every x time...

HotKeySet("{F9}", "terminate")

mainscript....

Func terminate()
    Return 0
    EndFunc
There is no method for exiting a function except Return, or reaching the end of the function (exiting the loop). You could have the function periodically check a Global flag variable and Return/ExitLoop when something else changes that.
Global $f_Run = True

HotKeySet("{F9}", "terminate")

_Main()

Func _Main()
    While $f_Run
        Sleep(10)
    WEnd
EndFunc
MsgBox(64, "Done", "Done.")

Func terminate()
    $f_Run = False
EndFunc

:)

Edit: Clarity.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...