Jump to content

Recommended Posts

Posted (edited)

Hello

I'm currently working with your UIAutomation_Extended.au3 

I'm trying to achieve a specific goal: automate the process of extracting OCR result text from the Windows 11 Photos app (after clicking the "Scan Text" button on an image).

So far, I’ve been able to:

  • Locate and click the “Scan Text” button using UIA (specifically, the OcrButton AutomationId).

  • Wait for the OCR to complete, and detect that a new element labeled img (1).jpg appears in the UIA tree, with ControlType 50032 (Text).

However, I'm running into an issue:
Even though this element appears after OCR has been triggered, and seems like it should contain the result, but i cannot figure out how to fetch the result, here is my code

 

#include <UIAutomation_Extended.au3>
;~ ; Initialize UI Automation
Local $oUIA = _UIA_InitInterface()
Local $oRoot = _UIA_GetRootElement($oUIA)

; Find Photos window element by Name
Local $oCondition = _UIA_CreatePropertyCondition($oUIA, $UIA_ClassNamePropertyId , "WinUIDesktopWin32WindowClass")
Local $oCalc = _UIA_FindFirst($oRoot, $oCondition, $TreeScope_Descendants)

; Find the "Scan Text" button using its AutomationId
$oCondition = _UIA_CreatePropertyCondition($oUIA, $UIA_AutomationIdPropertyId, "OcrButton")
Local $oBtn1 = _UIA_FindFirst($oCalc, $oCondition, $TreeScope_Descendants)

;~ ; Invoke the button (Toggle)
Local $oPattern = _UIA_GetCurrentPattern($oBtn1, $UIA_TogglePatternId)
$oPattern.Toggle()
 

Would you happen to know if:

  1. The Photos app renders OCR text in a way that's not accessible via standard TextPattern or ValuePattern?

  2. There’s a workaround with your UDF (perhaps using LegacyIAccessible, RawViewWalker, or something low-level)?

  3. You’ve seen similar behavior with modern UWP/XAML apps using Canvas-like rendering?

Any advice or insight you can provide would be greatly appreciated.

Thanks

2025-07-31_14-58.png

Edited by fraizor

AutoFox, A Modern, Simple, No dependency, Noob friendly yet powerful Firefox UDF !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...