BigDaddyO Posted January 15, 2019 Share Posted January 15, 2019 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 More sharing options...
junkew Posted January 15, 2019 Share Posted January 15, 2019 You should check with inspect.exe if the pattern is available. If it is you should be able to get it although i am not 100% sure all cuiautomation2 definitions are correct. Maybe later this week i will check. FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
BigDaddyO Posted January 16, 2019 Author Share Posted January 16, 2019 I just checked the Inspect.exe on that control, and it looks like it doesn't use Pattern. I guess I'll start looking into other options to try and modify the image once captured before doing the OCR. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now