
Greetings, all! I want to extract a list of all of the open windows for a specific application, but I can't seem to figure out the most efficient way to do that. Anyone have thoughts? I don't want to have to program a mouse hover and then extract if I can help it.
This gets each window looping through them by using Alt + Tab. This specific setup is to pull windows name, but if you wanted to, you could pull %AutomationWindow% instead which would pull the process ID and you use the %AutomationWindow% to use Get Window Details for anything besides title and process id. Once you have the %AllWindows% list, you could do another loop on the list for "If doesn't contain Excel (for example), delete from list.
Good luck!
UIAutomation.GetWindow.GetForegroundWindow WindowTitle=> WindowTitle WindowInstance=> AutomationWindow
Variables.CreateNewList List=> AllWindows
Variables.AddItemToList Item: WindowTitle List: AllWindows
LOOP LoopIndex FROM 1 TO 99 STEP 1
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''{Alt}({Tab:%LoopIndex%})''' DelayBetweenKeystrokes: 100 SendTextAsHardwareKeys: False
WAIT 1
UIAutomation.GetWindow.GetForegroundWindow WindowTitle=> WindowTitle WindowInstance=> AutomationWindow
IF WindowTitle = AllWindows[LoopIndex - 1] THEN
EXIT LOOP
ELSE
Variables.AddItemToList Item: WindowTitle List: AllWindows
END
END