Jump to content

Ending a function with a hotkey?


Recommended Posts

I have several functions within a script that I'm trying to call on hotkeys. The problem with these functions is they have serveral Do Untils and While Wends within them. Is there a way to force the function to end prematurely with a hotkey? I tried setting a function to a hotkey and the $var = Not $var thing, but it won't end until the Do untils finish.

Link to comment
Share on other sites

  • Moderators

Your probably calling other functions that take time to return onto the next line of the Do/Until-While/WEnd, so you see the delay in kill time.

You might think of having a global kill variable. Then in these other functions/loops check the value of it (kind of like inputting debug code, you'll be using it alot).

Pseudo code may look like:

Global $f_stop_functions = False
HotKeySet("{ESC}", "_Kill_Functions")

While 1
    Sleep(100000)
WEnd

Func _Kill_Functions()
    $f_stop_functions = Not $f_stop_functions
EndFunc

Func _SomeFunction()
    If Not $f_stop_functions Then Return
    While 1
        Sleep(10)
        If Not $f_stop_functions Then Return
        ;Do Something
        Do
            Sleep(10)
            ;Do something
            If Not $f_stop_functions Then Return
        Until $other_condition = $something
    WEnd
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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