WinWaitClose blocks Timer call Topic is solved

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

WinWaitClose blocks Timer call

Post by Rohwedder » 19 May 2024, 01:47

[Moderator's note: Topic moved from Bug Reports.]

Hallo,
The manual says about WinWaitClose:
https://www.autohotkey.com/docs/v1/lib/WinWaitClose.htm#Remarks
While the command is in a waiting state, new threads can be launched via hotkey, custom menu item, or timer.
But that obviously doesn't always work!:

Code: Select all

#Requires AutoHotkey v1.1.33
#Persistent
DetectHiddenWindows, On
one() {
	SoundBeep, 4000, 20
}
two() {
	SoundBeep, 1000, 20
	WinWaitClose, ahk_id %A_ScriptHwnd%
}
SetTimer, one, 1000
SetTimer, two, 2000
or:

Code: Select all

#Requires AutoHotkey v2.0
Persistent
DetectHiddenWindows True
one() {
	SoundBeep 4000, 20
}
two() {
	SoundBeep 1000, 20
	WinWaitClose "ahk_id " A_ScriptHwnd
}
SetTimer one, 1000
SetTimer two, 2000
This only happens if the two timer periods are somehow evenly related.
just me
Posts: 9551
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WinWaitClose blocks Timer call  Topic is solved

Post by just me » 19 May 2024, 02:53

SetTimer -> Remarks
Reliability: A timer might not be able to run at the expected time under the following conditions:
  1. ...
  2. The timer's function is still running when the timer period expires again.
  3. ...
  4. The timer has been interrupted by another thread, namely another timed function, hotkey subroutine, or custom menu item (this can be avoided via Critical). If this happens and the interrupting thread takes a long time to finish, the interrupted timer will be effectively disabled for the duration. However, any other timers will continue to run by interrupting the thread that interrupted the first timer.
  5. ...
Rohwedder
Posts: 7735
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: WinWaitClose blocks Timer call

Post by Rohwedder » 19 May 2024, 03:05

Should have thought of that myself!
Post Reply

Return to “Ask for Help (v2)”