Autohotkey:获取具有特定标题的窗口列表

Jac*_*azz 6 autohotkey

我正在创建一个AutoHotkey脚本,当出现具有特定标题或类ID的窗口时,会在其中绘制一个区域.问题是有时会出现多个这样的窗口,它们都具有相同的标题和类ID.在这种情况下,我的脚本无法全部检测到它们,只在活动窗口内绘制一个区域.

是否有可能获得与标题或类ID匹配的所有窗口的句柄列表,或者以其他方式在AHK中循环遍历所有窗口?谢谢

Sea*_*anC 5

WinGet使用该list命令将生成一个句柄数组

Winget, id, list, MyTitle 然后循环遍历它们,并处理......

从帮助文件:

; Example #2: This will visit all windows on the entire system and display info about each of them:
WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    WinActivate, ahk_id %this_id%
    WinGetClass, this_class, ahk_id %this_id%
    WinGetTitle, this_title, ahk_id %this_id%
    MsgBox, 4, , Visiting All Windows`n%a_index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue?
    IfMsgBox, NO, break
}
Run Code Online (Sandbox Code Playgroud)