AHK 设置 window title 如果它包含

AHK set window title if it contains

我正在尝试为每个 window 使用 AHK 的正则表达式设置标题。

settitlematchmode regex

ifwinexist, Title
{
WinSetTitle, New Title
}

WinGet .. 还可以检索所有 windows 符合指定条件(WinTitle、WinText)的列表。

F1::
SetTitleMatchMode, regex
WinGet, id, list, Title
Loop, %id%
{
    this_ID := id%A_Index%
    WinSetTitle, ahk_id %this_ID%,, New Title
}
return

编辑:

ahk_id 用于根据 windows unique id 识别 window (hwnd).

要获得此 window 的(准确)标题,请使用:

F1::
SetTitleMatchMode, regex
WinGet, id, list, Title
Loop, %id%
{
    this_ID := id%A_Index%
    WinGetTitle, exact_title, ahk_id %this_ID%
        MsgBox, %exact_title%       
    WinSetTitle, ahk_id %this_ID%,, New Title
}
return