HotIfWinActive [WinTitle, WinText] ... WinTitle and WinText have the same meaning as for WinActive or WinExist ... See WinTitle for details.
https://lexikos.github.io/v2/docs/misc/WinTitle.htm#ahk_id
Use ahk_id HWND, HWND (that is, without the ahk_id keyword) or ...
Gui and GuiControl objects have a Hwnd property and therefore can be used directly in WinTitle.
Code: Select all
MyGui := Gui()
MyGui.Show("y300 w150 h100")
HotIfWinActive(MyGui.Hwnd) ;fail despite allowed in doc
;HotIfWinActive(MyGui) ;fail despite allowed in doc
;HotIfWinActive("ahk_id " MyGui.Hwnd) ;success
HotKey("LButton", GuiClick)
return
GuiClick(*) {
if WinExist(MyGui.Hwnd) ;success
MsgBox(A_ThisHotkey)
}