Jump to content

IUIAutomation Get/Set Background color


Recommended Posts

Hello,  I'm in need of changing the background color of a control if it's not white.  I'm doing a screencapture of the control to do OCR on, but am having some difficulties with Bold text not being read all the time.  I came across a few posts that say to set the background to white if possible to increase the OCR capabilities, but that is easier said than done.

 

Here is what I have so far, along with a link to a site that shows how to get the background color from UI-Automation, but I can't figure out how to integrate that with the AutoIt IUI automation.  Anyone have some hints or other ideas?

https://stackoverflow.com/questions/23199361/white-ui-automation-framework-back-colour

 

This gets the control, I have the console output I receive added as comments

#Include ".\Include\UIAWrappers.au3"

;Change the background color of a control so OCR can more easily identify words!
Local $oP5=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Facets - Subscriber/Family;controltype:=UIA_WindowControlTypeId;class:=Afx", $treescope_children)
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=Workspace;controltype:=UIA_PaneControlTypeId;class:=MDIClient", $treescope_children)
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=Subscriber/Family;controltype:=UIA_WindowControlTypeId;class:=Afx", $treescope_children)
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=Subscriber/Family;controltype:=UIA_PaneControlTypeId;class:=Afx", $treescope_children)
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=AfxWnd140", $treescope_children)
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=AfxWnd140", $treescope_children)
_UIA_Action($oP0, "setfocus")
_UIA_Action($oP0,"highlight")

$sRect = _UIA_getPropertyValue($oP0, $UIA_BoundingRectanglePropertyId)      ;Get the coords of the control for ScreenCapture
ConsoleWrite("Rect = " & $sRect & @CRLF)
;Rect = 302;497;865;291

;Want to Get and Set $UIA_BackgroundColorAttributeId
$oCtrl = _UIA_getObject($oP0)
$oTxtPtrn = _UIA_getPattern($oCtrl, $UIA_TextPatternId)
ConsoleWrite("GetObject = (" & $oCtrl & ") and GetPattern = (" & $oTxtPtrn & ")" & @CRLF)
;GetObject = () and GetPattern = (UIA WARNING ** NOT ** found the pattern)

;Found this on manually getting info, but cant figure out how to use...
;https://stackoverflow.com/questions/23199361/white-ui-automation-framework-back-colour

 

Thanks,

Mike

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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