Stop looping thread without killing script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
WeThotUWasAToad
Posts: 312
Joined: 19 Nov 2013, 08:44

Stop looping thread without killing script

01 Sep 2020, 14:04

Hello,

Is there a way to stop or interrupt a looping thread without killing the script (ie without closing the .ahk file)?

Suppose you have a script which contains several threads (each with its own hotkey), and suppose one of the threads has a Loop, 99 command. Once you press the hotkey to begin running the looping thread, is there a way to designate another keystroke or mouse action which will stop or pause the looping thread but leave the script open?

Thanks
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word. It never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Stop looping thread without killing script  Topic is solved

01 Sep 2020, 14:34

Exit

Code: Select all

1::
    stop := false
    Loop, 99
    {
        ToolTip, % "testing..." . A_Index
        if (stop = true)
        {
            ToolTip
            Exit
        }
        Sleep 1000
    }
    MsgBox, % A_ThisHotkey . " run completed."
return

2::stop := true
WeThotUWasAToad
Posts: 312
Joined: 19 Nov 2013, 08:44

Re: Stop looping thread without killing script

01 Sep 2020, 15:19

Thanks Xtra,

What a great and clever solution!

That's just what I needed.

Thanks again.
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT

"ALOT" is not a word. It never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], madensuyu1, Rohwedder, sachalamp and 137 guests