Kill Underlying Thread with Hotkey

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mangoninja
Posts: 3
Joined: 26 Jul 2017, 19:58

Kill Underlying Thread with Hotkey

26 Jul 2017, 20:20

Hi,

I have searched many posts about this but the solution is not feasible for some of my more complicated scripts. I understand that there is no global 'Exit' command to kill ALL threads and leave the script active.

Most workarounds involve assigning a break = 1 variable to a hotkey. While the loop is constantly checking to see if break = 1 to then exit the thread. Which is fine if your loop has only a few lines. But my loop contains HUNDREDS of tasks. I want to be able to kill that thread instantly. The workaround that I have put in place is silly. I have a Check(Break) function every few lines or so to basically take a quick peek to see if its ok to continue. Is there a way to check if Break = 1 with every new line of code?

Or at least may I offer an 'Exit, All' suggestion. Or a 'soft reload' so to speak.
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Kill Underlying Thread with Hotkey

26 Jul 2017, 20:53

I'm not aware of anything besides what you've mentioned, but you may consider running them on literally different threads using AutoHotkey_H's multi-threading DLL. I have an implementation you may use here: threadMan.ahk
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
mangoninja
Posts: 3
Joined: 26 Jul 2017, 19:58

Re: Kill Underlying Thread with Hotkey

27 Jul 2017, 22:53

Thanks Masonjar I was after a more vanilla solution without needing extra libraries.
TAC109
Posts: 1111
Joined: 02 Oct 2013, 19:41
Location: New Zealand

Re: Kill Underlying Thread with Hotkey

27 Jul 2017, 23:12

Using a

Code: Select all

reload
command would achieve the same effect.
My scripts:-
XRef - Produces Cross Reference lists for scripts
ReClip - A Text Reformatting and Clip Management utility
ScriptGuard - Protects Compiled Scripts from Decompilation
I also maintain Ahk2Exe
AHMe
Posts: 3
Joined: 16 Aug 2017, 06:08

Re: Kill Underlying Thread with Hotkey

21 Aug 2017, 21:32

Thank you TAC109 for your post! This achieves the functionality that I've been looking for.

I was expecting there to be/hoping for (as mangoninja said) a "global 'Exit' command to kill ALL threads and leave the script active", but I hadn't found anything.

FYI, here's my post below
https://autohotkey.com/boards/viewtopic ... 73#p166273
Nick A
Posts: 7
Joined: 03 Jul 2019, 07:48

Re: Kill Underlying Thread with Hotkey

27 Apr 2022, 17:58

A 'soft reload' can be achieved by dumping any variables you want to keep to an ini file and then reloading the script. The script can then read the ini file and go from there.

See:
https://www.autohotkey.com/docs/commands/IniRead.htm
https://www.autohotkey.com/docs/commands/IniWrite.htm

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 306 guests