Simultaneous running of two timers. Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Rohwedder
Posts: 7772
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Simultaneous running of two timers.

Post by Rohwedder » 15 Mar 2024, 12:47

An Autohotkey v1 or v2 script always has exactly one active thread!

Perhaps?:

Code: Select all

#Requires AutoHotkey v2.0
q::SoundBeep(4000, 20), SleepBreak(35000, "Esc"), SoundBeep(1000, 20)
SleepBreak(Time, Break_Key)
{
	End:= A_TickCount + Time
	While S:= End-A_TickCount > 0
		IF !GetKeyState(Break_Key, "P")
			Sleep(S>50?50:S)
		Else Break
}

hiahkforum
Posts: 47
Joined: 08 Feb 2024, 04:21

Re: Simultaneous running of two timers.

Post by hiahkforum » 15 Mar 2024, 14:14

@Rohwedder You are just a legendary man! :superhappy: I heard that AHK is single-threaded, but the fact is that this Loop thing doesn’t work as it should, and the usual Sleep does, but in the end your solution works, as always, absolutely like a charm! :D

Post Reply

Return to “Ask for Help (v2)”