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 / Count the number of ti...
Power Automate
Answered

Count the number of times a window contains text

(0) ShareShare
ReportReport
Posted on by 31

I would like to count the number of times text is found in a window and then pick the last one down the page most likely using "Move mouse to text on screen (OCR)" which allows me to set the occurrence.

Thank you

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Quick question:  is all the text visible on the screen, or do you possibly need to scroll down?

  • SM-03042006-0 Profile Picture
    31 on at

    It is all visible

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    First, extract text with OCR.

    Then Parse; this gives a list of positions.  You can then you positions.count to determine the occurrence:

     

    MichaelAnnis_0-1680607006194.png

     

    This worked on the screen for this post.  Here is the code; you should be able to copy and paste into your flow:

    WebAutomation.LaunchChrome.AttachToChromeByUrl TabUrl: $'''https://powerusers.microsoft.com/t5/Power-Automate-Desktop/Count-the-number-of-times-a-window-contains-text/m-p/2095500/thread-id/24911''' AttachTimeout: 5 BrowserInstance=> Browser
    OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
    Text.ParseText.Parse Text: OcrText TextToFind: $'''Microsoft''' StartingPosition: 0 IgnoreCase: False OccurrencePositions=> Positions
    MouseAndKeyboard.MoveMouseToTextOnScreenWithOCR.WaitForTextToAppearAndMoveMouseToTextOnScreenWithWindowsOcr TextToFind: $'''Microsoft''' IsRegEx: False WindowsOcrLanguage: MouseAndKeyboard.WindowsOcrLanguage.English Occurence: Positions.Count SearchForTextOn: MouseAndKeyboard.SearchTarget.EntireScreen ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 MovementStyle: MouseAndKeyboard.MovementStyle.Instant Timeout: 5 PositionRelativeToText: MouseAndKeyboard.PositionOnImage.MiddleCenter OffsetX: 0 OffsetY: 0 X=> LocationOfTextFoundX Y=> LocationOfTextFoundY Width=> WidthOfTextFound Height=> HeightOfTextFound

     

    Ensure on Parse Text you are using "First occurence only = False".

     

    Good luck!

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

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 355

#2
11manish Profile Picture

11manish 336 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard