Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

UIA Invoke click for a UIA_TextControlTypeId - Is that possible?

$
0
0

Good Morning AutoIT Gurus :)

 

How is everyone this fine Tuesday?  :thumbsup:

 

I have been using SimpleSpy and inspect.exe to get data from various program windows - but this one, I'm not sure about since it's a button - but it's also text.

 

Could I treat UIA_TextControlTypeID (TextBlock) as a button and click on it somehow? -  If so, how would I do that? FYI - I have successfully been using code examples from LarsJ and Junkew in the past.

 

The reason I have to treat that text as a button is that the button itself has no data. (At least we have an element [][Button]) and the text within the button does... (At least we have an element [Run Threat Analysis Scan][TextBlock])

 

:idea:  SimpleSpy info:

 

Mouse position is retrieved 486-377
At least we have an element [Run Threat Analysis Scan][TextBlock]
 
Having the following values for all properties: 
Title is: <Run Threat Analysis Scan> Class   := <TextBlock> controltype:= <UIA_TextControlTypeId> ,<50020> , (0000C364) 397;367;154;16
*** Parent Information top down ***
7: Title is: <Desktop> Class   := <#32769> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 0;0;1920;1080
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"
6: Title is: <Symantec Help v2.1> Class   := <Window> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) 322;65;1024;680
"Title:=Symantec Help v2.1;controltype:=UIA_WindowControlTypeId;class:=Window"
5: Title is: <> Class   := <SharedWindow> controltype:= <UIA_CustomControlTypeId> ,<50025> , (0000C369) 330;143;1008;572
"Title:=;controltype:=UIA_CustomControlTypeId;class:=SharedWindow"
4: Title is: <> Class   := <Home2> controltype:= <UIA_CustomControlTypeId> ,<50025> , (0000C369) 342;193;996;522
"Title:=;controltype:=UIA_CustomControlTypeId;class:=Home2"
3: Title is: <> Class   := <ScrollViewer> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 342;193;996;522
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ScrollViewer"
2: Title is: <> Class   := <Ui2Widget> controltype:= <UIA_CustomControlTypeId> ,<50025> , (0000C369) 357;250;263;169
"Title:=;controltype:=UIA_CustomControlTypeId;class:=Ui2Widget"
1: Title is: <> Class   := <UiActionButton> controltype:= <UIA_CustomControlTypeId> ,<50025> , (0000C369) 357;355;263;40
"Title:=;controltype:=UIA_CustomControlTypeId;class:=UiActionButton"
0: Title is: <> Class   := <Button> controltype:= <UIA_ButtonControlTypeId> ,<50000> , (0000C350) 357;355;263;40
"Title:=;controltype:=UIA_ButtonControlTypeId;class:=Button"
 
#include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) Local $oP6=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Symantec Help v2.1;controltype:=UIA_WindowControlTypeId;class:=Window", $treescope_children)  _UIA_Action($oP6,"setfocus") Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_CustomControlTypeId;class:=SharedWindow", $treescope_children)   Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_CustomControlTypeId;class:=Home2", $treescope_children)  Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ScrollViewer", $treescope_children) Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_CustomControlTypeId;class:=Ui2Widget", $treescope_children)  Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_CustomControlTypeId;class:=UiActionButton", $treescope_children) Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_ButtonControlTypeId;class:=Button", $treescope_children) ;~ First find the object in the parent before you can do something ;~$oUIElement=_UIA_getObjectByFindAll("RunThreatAnalysisScan.mainwindow", "title:=Run Threat Analysis Scan;ControlType:=UIA_TextControlTypeId", $treescope_subtree) Local $oUIElement=_UIA_getObjectByFindAll($oP0, "title:=Run Threat Analysis Scan;ControlType:=UIA_TextControlTypeId", $treescope_subtree) _UIA_action($oUIElement,"click")

This fails as well...

 

Window handle OK
UI Automation object OK
Automation element from window OK
Run Threat Analysis Scancondition OK
Find button ERR
 
AutoIt         
    Local $hWindow = WinGetHandle("Symantec Help v2.1")     If Not $hWindow Then Return ConsoleWrite("Window handle ERR" & @CRLF)     ConsoleWrite("Window handle OK" & @CRLF)     ; Create UI Automation object     Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation)     If Not IsObj($oUIAutomation) Then Return ConsoleWrite("UI Automation object ERR" & @CRLF)     ConsoleWrite("UI Automation object OK" & @CRLF)     ; Get UI Automation element from window handle     Local $pWindow, $oWindow     $oUIAutomation.ElementFromHandle($hWindow, $pWindow)     $oWindow = ObjCreateInterface($pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)     If Not IsObj($oWindow) Then Return ConsoleWrite("Automation element from window ERR" & @CRLF)     ConsoleWrite("Automation element from window OK" & @CRLF)     ; Condition to find "Run Threat Analysis Scan" button     Local $pCondition, $pCondition1, $pCondition2     $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1)     $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, "Run Threat Analysis Scan", $pCondition2)     $oUIAutomation.CreateAndCondition($pCondition1, $pCondition2, $pCondition)     If Not $pCondition Then Return ConsoleWrite("Run Threat Analysis Scan condition ERR" & @CRLF)     ConsoleWrite("Run Threat Analysis Scancondition OK" & @CRLF)     ; Find "Run Threat Analysis Scan" button     Local $pButton, $oButton     $oWindow.FindFirst($TreeScope_Descendants, $pCondition, $pButton)     $oButton = ObjCreateInterface($pButton, $sIID_IUIAutomationElement, $dtagIUIAutomationElement)     If Not IsObj($oButton) Then Return ConsoleWrite("Find button ERR" & @CRLF)     ConsoleWrite("Find button OK" & @CRLF)     ; Click (invoke) "Run Threat Analysis Scan" button     Local $pInvoke, $oInvoke     $oButton.GetCurrentPattern($UIA_InvokePatternId, $pInvoke)     $oInvoke = ObjCreateInterface($pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern)     If Not IsObj($oInvoke) Then Return ConsoleWrite("Invoke pattern ERR" & @CRLF)     ConsoleWrite("Invoke pattern OK" & @CRLF)     $oInvoke.Invoke()     Sleep(2000)

Thank you all very much - I do appreciate your help as always.  :ILA:

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>