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 / Check if OCRText has v...
Power Automate
Unanswered

Check if OCRText has value

(0) ShareShare
ReportReport
Posted on by 8

Dear All ,

How to make flow that when OCR has any value do something and if there is no value in OCRText keep looping until find any data ( Characters or numbers)

  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    Hi @shod90 

    As per my understanding, you are trying to read the data using OCR and the output is OCRText.

     

    use loop condition and or for each activity 

    then loop through the item

    then use If condition and 

    give the Vraible OCRText in the first operand and then is not empty as shown below image.

     

    UshaJyothi20_0-1718335092537.png

     

    Hope this helps,

    Usha.

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @shod90 ,

     

    Please find the solution.

    VishnuReddy1997_0-1718339683048.png

    Code:

    Please copy and paste this code to your flow.

    OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
    LOOP WHILE (True) = (True)
     IF IsNotEmpty(OcrText) THEN
     EXIT LOOP
     END
     OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

     

  • shod90 Profile Picture
    8 on at

    I don't know why this flow not working for me , This flow should exit the loop if it's found a text inOCRtext , Right ?

    Actually on my pc on both cases it exits !

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @shod90 ,

     

    Can you share the screenshot of your flow.

     

    Regards,

    Vishnu Reddy 

  • shod90 Profile Picture
    8 on at

    Hi @VishnuReddy1997 ,

    Here is my flow , As u can see the OCRtext variable is empty but it goes inside the if condition for OCRText not empty .

    shod90_0-1718539156291.png

  • shod90 Profile Picture
    8 on at

    @VishnuReddy1997 , Here i changed the if condition and it's working , But i need to make this condition general on any character not only P , So i need to say if it's contain any letter then do something , Else do another thing 

    shod90_0-1718540117491.png

     

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @shod90 ,

     

    The OCRText variable may contain Voidspaces.So just use trim text as shown in below image.

    VishnuReddy1997_0-1718599308920.png

     

    Code:

    OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
    Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    LOOP WHILE (True) = (True)
     IF IsNotEmpty(OcrText) THEN
     EXIT LOOP
     END
     OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
     Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • shod90 Profile Picture
    8 on at

    Hi @VishnuReddy1997 ,

    Unfortunately not working also i don't why 😞 , both cases if it's empty or not empty it exits the loop.

    Did u tried that on ur computer already ? 

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @shod90 

     

    Please follow the below flow for contains approach:

     

    In the below flow, I have included variable called SearchText to mention your text or char to check in the extracted OCRTEXT and also i have added messagebox to display ocr text before goes into if condition so that it will give some idea on what is being extracted through OCR on each time extraction.

     

    Deenuji_0-1718614142520.png

    You can declare variable like searchtext and use that variable in if condition second operand like below.

     

    Deenuji_1-1718614202535.png

     

     

    Code:

     

    SET SearchText TO $'''Power'''
    OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
    Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    LOOP WHILE (True) = (True)
     Display.ShowMessageDialog.ShowMessage Title: $'''Info''' Message: $'''Extracted Text: %OcrText%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
     IF Contains(OcrText, SearchText, True) THEN
     EXIT LOOP
     END
     OCR.ExtractTextWithOCR.ExtractTextFromScreenWithWindowsOcr WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
     Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    END

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @shod90 ,

     

    Ya I have tried.Its working.Just try to change the setting in ocr activity,instead of screen,just try thr image in bot the Extract Ocr as shown in below image.

    VishnuReddy1997_0-1718614185944.png

    VishnuReddy1997_1-1718614265383.png

     

    Updated Code:

    OCR.ExtractTextWithOCR.ExtractTextFromFileWithWindowsOcr ImageFile: $'''C:\\Users\\OneDrive \\Desktop\\OCR.jpg''' WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 4 ImageHeightMultiplier: 4 OcrText=> OcrText
    Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    LOOP WHILE (True) = (True)
     IF IsNotEmpty(OcrText) THEN
     EXIT LOOP
     END
     OCR.ExtractTextWithOCR.ExtractTextFromFileWithWindowsOcr ImageFile: $'''C:\\Users\\OneDrive \\Desktop\\OCR.jpg''' WindowsOcrLanguage: OCR.WindowsOcrLanguage.English ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 OcrText=> OcrText
     Text.Trim Text: OcrText TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

     

     

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
11manish Profile Picture

11manish 237 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 194

Last 30 days Overall leaderboard