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

Notifications

Announcements

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)

I have the same question (0)
  • UshaJyothiKasibhotla Profile Picture
    203 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,656 Super User 2025 Season 2 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,656 Super User 2025 Season 2 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,656 Super User 2025 Season 2 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 ? 

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 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,656 Super User 2025 Season 2 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard