Reputation:
I opened a window whose part of title is a.txt and I use AutoHotKey to find it.
WinGet, p_txt, ProcessName, txt
WinGet, p_atxt, ProcessName, a.txt
ListVars
It shows when search criteria is txt, p_txt has no value; when criteria is a.txt, p_atxt has value.
Why can WinGet, p_atxt, ProcessName, a.txt
find my window but WinGet, p_txt, ProcessName, txt
cannot?
Upvotes: 1
Views: 1029
Reputation: 4065
The matching behavior if window titles is determined by SetTitleMatchMode.
Amongst others, there are these modes:
1: A window's title must start with the specified WinTitle to be a match.
2: A window's title can contain WinTitle anywhere inside it to be a match.
3: A window's title must exactly match WinTitle to be a match.
SetTitleMatchMode, 2
is what you're looking for.
Upvotes: 1