user746461
user746461

Reputation:

Autohotkey: WinGet cannot find window with WinTitle as txt, but can with a.txt

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.enter image description here

Why can WinGet, p_atxt, ProcessName, a.txt find my window but WinGet, p_txt, ProcessName, txt cannot?

Upvotes: 1

Views: 1029

Answers (1)

MCL
MCL

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

Related Questions