web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Trying to iterate thro...
Power Automate
Unanswered

Trying to iterate through open windows

(0) ShareShare
ReportReport
Posted on by 3

Hi - new to PAD, have been searching for an answer to my issue but haven't found anything so far.

 

I'd like to find the titles of existing open web browser pages, and put that into a list variable. I'd also like to do the same with open Excel documents. 

 

This must be possible to do, right?

 

thanks for any assistance! 

I have the same question (0)
  • VJR Profile Picture
    7,635 on at

    Hi @sholland 

     

    There would be several scripts (Vbs, Powershell, VBA macro, etc) available on the web to get window details based on the process name (Chrome/Excel).

    Probably it would be easier to have that script write to a Text file or spreadsheet and call the script from PAD and write the details retrieved into a list variable.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    I created a flow that iterates through each open window and uses "Get Window" to pull the window title and handle ID.  It iterates through using the {Alt}({Tab}) shortcut key.  Inside of a loop determines how many {Tab}s there are.  It stops when the current handle matches the previous handle.  Copy and paste the below into a subflow, and it should run no problem.  Best of Luck!

     

    Variables.CreateNewList List=> AllOpenWindowTitles
    Variables.CreateNewList List=> AllOpenAutomationWindows
    UIAutomation.Windows.GetForegroundWindow WindowTitle=> WindowTitle WindowInstance=> AutomationWindow
    Variables.AddItemToList Item: WindowTitle List: AllOpenWindowTitles NewList=> AllOpenWindowTitles
    Variables.AddItemToList Item: AutomationWindow List: AllOpenAutomationWindows NewList=> AllOpenAutomationWindows
    LOOP LoopIndex FROM 1 TO 99 STEP 1
    MouseAndKeyboard.PressKey Control: False Alt: True Shift: False Win: False
    LOOP LoopIndex3 FROM 1 TO LoopIndex STEP 1
    MouseAndKeyboard.SendKeys TextToSend: $'''{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    END
    MouseAndKeyboard.ReleaseKey Control: False Alt: True Shift: False Win: False
    WAIT 1
    UIAutomation.Windows.GetForegroundWindow WindowTitle=> WindowTitleNow WindowInstance=> AutomationWindowNow
    IF LoopIndex > 1 THEN
    IF AutomationWindowNow.Handle = AutomationWindowPrevious.Handle THEN
    EXIT LOOP
    END
    END
    Variables.AddItemToList Item: WindowTitleNow List: AllOpenWindowTitles NewList=> AllOpenWindowTitles
    Variables.AddItemToList Item: AutomationWindowNow List: AllOpenAutomationWindows NewList=> AllOpenAutomationWindows
    SET AutomationWindowPrevious TO AutomationWindowNow
    END

  • sholland Profile Picture
    3 on at

    Thank you for @MichaelAnnis and @VJR for responding!

     

    I've found a nifty PowerShell method to get the Excel file list here: Find all window titles of application through command line - Super User  and that works quite quickly. It doesn't get me a list of Edge tabs, however, so I'm still on the lookout for code that will do that.

  • VJR Profile Picture
    7,635 on at

    Hi @sholland 

    You'll get it....Keep looking. Also try looking for Chrome ones and see by replacing it with Edge in the process name.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 190

Last 30 days Overall leaderboard