Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autohotkey: get list of windows with a certain title

Tags:

autohotkey

I'm making an AutoHotkey script that, when a window with a certain title or class ID appears, draws a region inside it. The problem is that sometimes multiple such windows can appear, all having the same title and class ID. In that case my script cannot detect them all and only draws a region inside the active window.

Is it possible to get a list of handles of all windows matching the title or class ID or in some other way cycle through all of them in AHK? Thanks

like image 260
Jackie Spazz Avatar asked May 24 '12 15:05

Jackie Spazz


1 Answers

WinGet with the list command will produce an array of handles

Winget, id, list, MyTitle then loop through them, and process...

from the help file:

; 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
}
like image 188
SeanC Avatar answered Oct 04 '22 23:10

SeanC