Essentially, WinExist() and IfwinExist always fail, unless the window handle is also passed as part of the window Identifier. Not sure if it's always been this way, or new since 1.1.27.03.
I wrote the following, to investigate the issue, which should also serve as a proof of concept. There are comments in below code for results on variations. It's just a basic script which should display a tooltip whenever it detects the window on a LButton press. The idea is to open windows you know should work, i.e. with a class = "Windows.UI.Core.CoreWindow" and/or belonging to ShellExperienceHost.exe, (eg Start Menu, Jump Lists, Volume Control, Network Connections), and then click inside them (ideally on a blank section that does nothing), to see what is/isn't detected.
Code: Select all
CoordMode, Tooltip, Screen
SetTitleMatchMode, 1
txt := ""
Esc:: Tooltip
~LButton::
DetectHiddenWindows, On
;These Never work
If WinExist("ahk_class Windows.UI.Core.CoreWindow ahk_exe ShellExperienceHost.exe")
txt .= "ahk_class Windows.UI.Core.CoreWindow ahk_exe ShellExperienceHost.exe Detected`n"
If WinExist("ahk_class Windows.UI.Core.CoreWindow")
txt .= "ahk_class Windows.UI.Core.CoreWindow Detected`n"
If WinExist("ahk_exe ShellExperienceHost.exe")
txt .= "ahk_exe ShellExperienceHost.exe Detected`n"
If WinExist("Volume Control")
txt .= "Volume Control Detected`n"
If WinExist("Network Connections")
txt .= "Network Connections Detected`n"
IfWinExist ahk_exe ShellExperienceHost.exe
txt .= "non function ShellExperienceHost.exe`n"
IfWinExist ahk_class Windows.UI.Core.CoreWindow
txt .= "non function Windows.UI.Core.CoreWindow`n"
;These also never work (thought they might given start as title only entry below)
If WinExist("Start ahk_class Windows.UI.Core.CoreWindow ahk_exe ShellExperienceHost.exe")
txt .= "Start Menu with Class & Exe Detected"
If WinExist("Start ahk_class Windows.UI.Core.CoreWindow")
txt .= "Start Menu with Class Detected"
If WinExist("Start ahk_exe ShellExperienceHost.exe")
txt .= "Start Menu with Exe Detected"
DetectHiddenWindows, Off
;If DetectHiddenWindows not turned off, following start as title is always detected, when off it's never detected.
If WinExist("Start")
txt .= "Start Menu Detected`n"
;Following all work correctly (i.e. if the window handle is also passed):
MouseGetPos,,,win,ctl
If WinExist("ahk_class Windows.UI.Core.CoreWindow ahk_exe ShellExperienceHost.exe AHK_id " win)
txt .= "ahk_class Windows.UI.Core.CoreWindow ahk_exe ShellExperienceHost.exe AHK_id %win% Detected`n"
If WinExist("ahk_class Windows.UI.Core.CoreWindow AHK_id " win)
txt .= "ahk_class Windows.UI.Core.CoreWindow AHK_id %win% Detected`n"
If WinExist("ahk_exe ShellExperienceHost.exe AHK_id " win)
txt .= "ahk_exe ShellExperienceHost.exe AHK_id %win% Detected`n"
If txt
{
tooltip, %txt%,0,0
txt := ""
}
Return