Jump to content
Sign in to follow this  
Yokes9

Control type GXWND?

Recommended Posts

Yokes9

Hello,

I am having an issue with a Listbox or Grid or something... I have searched the forums and google and have found very little that is helpful. What I would like to do is get all the items in the list and put them in an array and also be able to select a specific item from the list. Right now I am doing it with a crude

Send ("^c")

Send ("{DOWN}")

combination and using that to compare to a predefined variable in my code. Stopping when they match and clicked enter.

I am able to get the other items on the GUI with these  

$Combobox = ControlGetHandle(WinGetHandle("[CLASS:#32770]"), "", "[CLASS:ComboBox; INSTANCE:1]")
_GUICtrlComboBoxEx_ShowDropDown($Combobox, True)
$list=_GUICtrlComboBoxEx_GetListArray($Combobox)

and

$Listbox = ControlGetHandle(WinGetHandle("[CLASS:#32770]"), "", "[CLASS:ListBox; INSTANCE:2]")
$ListBoxArray= _GUICtrlListBox_GetText($ListBox,5)

I have used this code to get data from some other "Hard to get" areas in this same Program but have not been able to get it to work for this. Not sure who wrote it but it has been very useful'

; Client UI Automation UDF
#include "CUIAutomation2.au3"

Opt( "MustDeclareVars", 1 )

MainFunc()

Func MainFunc()

  ; Section 1
  ; Get window handle
  Local $hWindow = WinGetHandle( "[CLASS:Afx:00100000:8:00010005:00000000:02EB144B]" )
  ; 00100000:8:00010005:00000000:02EB144B
  If Not $hWindow Then
    ConsoleWrite( "Window handle ERROR" & @CRLF )
    Return
  Else
    ConsoleWrite( "Window handle OK" & @CRLF )
  EndIf

  ; Section 2
  ; Create UI Automation object
  Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation )
  If Not IsObj( $oUIAutomation ) Then
    ConsoleWrite( "UI Automation object ERROR" & @CRLF )
    Return
  Else
    ConsoleWrite( "UI Automation object OK" & @CRLF )
  EndIf

  ; Section 3
  ; 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
    ConsoleWrite( "UI Automation element ERROR" & @CRLF )
    Return
  Else
    ConsoleWrite( "UI Automation element OK" & @CRLF )
  EndIf

  ; Section 4
  ; Condition to find tree item
  Local $pCondition
  $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_TreeItemControlTypeId, $pCondition )
  If Not $pCondition Then
    ConsoleWrite( "Condition ERROR" & @CRLF )
    Return
  Else
    ConsoleWrite( "Condition OK" & @CRLF )
  EndIf

  ; Section 5
  ; Find all tree items
  Local $pElementArray, $oElementArray, $iElements
  $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pElementArray )
  $oElementArray = ObjCreateInterface( $pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray )
  $oElementArray.Length( $iElements )
  If Not $iElements Then
    ConsoleWrite( "Find ERROR" & @CRLF )
    Return
  Else
    ConsoleWrite( "Find OK" & @CRLF )
  EndIf

  ; Section 6
  ; Print all tree item texts
  Local $pElement, $oElement, $sName
  For $i = 0 To $iElements - 1
    $oElementArray.GetElement( $i, $pElement )
    $oElement = ObjCreateInterface( $pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
    $oElement.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName )
    ConsoleWrite( $sName & @CRLF )
  Next

EndFunc

I don't know where/how to continue from here if anyone has done this or has suggestions I'd be open for anything. My coding knowledge is limited so you might have to dumb it down for me a little.

 

Relative websites:

http://msdn.microsoft.com/en-us/library/ms752044.aspx

'?do=embed' frameborder='0' data-embedContent>>

 

This is the SimpleSpy

Mouse position is retrieved 689-380
At least we have an element [AvailableTags:][GXWND]
Having the following values for all properties: 
Title is: <AvailableTags:>  Class   := <GXWND>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    
*** Parent Information ***
Title is: <Add/Configure Tags - TEST>   Class   := <#32770> controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    
*** Detailed properties of the highlighted element ***
UIA_AcceleratorKeyPropertyId :=
UIA_AccessKeyPropertyId :=Alt+v
UIA_AriaPropertiesPropertyId :=
UIA_AriaRolePropertyId :=
UIA_AutomationIdPropertyId :=225
UIA_BoundingRectanglePropertyId :=609;333;528;142
UIA_ClassNamePropertyId :=GXWND
UIA_ClickablePointPropertyId :=
UIA_ControllerForPropertyId :=
UIA_ControlTypePropertyId :=50033
UIA_CulturePropertyId :=0
UIA_DescribedByPropertyId :=
UIA_DockDockPositionPropertyId :=5
UIA_ExpandCollapseExpandCollapseStatePropertyId :=3
UIA_FlowsToPropertyId :=
UIA_FrameworkIdPropertyId :=Win32
UIA_GridColumnCountPropertyId :=0
UIA_GridItemColumnPropertyId :=0
UIA_GridItemColumnSpanPropertyId :=1
UIA_GridItemContainingGridPropertyId :=
UIA_GridItemRowPropertyId :=0
UIA_GridItemRowSpanPropertyId :=1
UIA_GridRowCountPropertyId :=0
UIA_HasKeyboardFocusPropertyId :=True
UIA_HelpTextPropertyId :=
UIA_IsContentElementPropertyId :=True
UIA_IsControlElementPropertyId :=True
UIA_IsDataValidForFormPropertyId :=False
UIA_IsDockPatternAvailablePropertyId :=False
UIA_IsEnabledPropertyId :=True
UIA_IsExpandCollapsePatternAvailablePropertyId :=False
UIA_IsGridItemPatternAvailablePropertyId :=False
UIA_IsGridPatternAvailablePropertyId :=False
UIA_IsInvokePatternAvailablePropertyId :=False
UIA_IsItemContainerPatternAvailablePropertyId :=False
UIA_IsKeyboardFocusablePropertyId :=True
UIA_IsLegacyIAccessiblePatternAvailablePropertyId :=True
UIA_IsMultipleViewPatternAvailablePropertyId :=False
UIA_IsOffscreenPropertyId :=False
UIA_IsPasswordPropertyId :=False
UIA_IsRangeValuePatternAvailablePropertyId :=False
UIA_IsRequiredForFormPropertyId :=False
UIA_IsScrollItemPatternAvailablePropertyId :=False
UIA_IsScrollPatternAvailablePropertyId :=True
UIA_IsSelectionItemPatternAvailablePropertyId :=False
UIA_IsSelectionPatternAvailablePropertyId :=False
UIA_IsSynchronizedInputPatternAvailablePropertyId :=False
UIA_IsTableItemPatternAvailablePropertyId :=False
UIA_IsTablePatternAvailablePropertyId :=False
UIA_IsTextPatternAvailablePropertyId :=False
UIA_IsTogglePatternAvailablePropertyId :=False
UIA_IsTransformPatternAvailablePropertyId :=False
UIA_IsValuePatternAvailablePropertyId :=False
UIA_IsVirtualizedItemPatternAvailablePropertyId :=False
UIA_IsWindowPatternAvailablePropertyId :=False
UIA_ItemStatusPropertyId :=
UIA_ItemTypePropertyId :=
UIA_LabeledByPropertyId :=
UIA_LegacyIAccessibleChildIdPropertyId :=0
UIA_LegacyIAccessibleDefaultActionPropertyId :=
UIA_LegacyIAccessibleDescriptionPropertyId :=
UIA_LegacyIAccessibleHelpPropertyId :=
UIA_LegacyIAccessibleKeyboardShortcutPropertyId :=Alt+v
UIA_LegacyIAccessibleNamePropertyId :=AvailableTags:
UIA_LegacyIAccessibleRolePropertyId :=10
UIA_LegacyIAccessibleSelectionPropertyId :=
UIA_LegacyIAccessibleStatePropertyId :=1048580
UIA_LegacyIAccessibleValuePropertyId :=
UIA_LocalizedControlTypePropertyId :=pane
UIA_MultipleViewCurrentViewPropertyId :=0
UIA_MultipleViewSupportedViewsPropertyId :=
UIA_NamePropertyId :=AvailableTags:
UIA_NativeWindowHandlePropertyId :=2557468
UIA_OrientationPropertyId :=0
UIA_ProcessIdPropertyId :=10600
UIA_ProviderDescriptionPropertyId :=[pid:20172,hwnd:0x27061C Main:Nested [pid:10600,hwnd:0x27061C Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:UIAutomationCore.DLL); Main:Microsoft: MSAA Proxy (unmanaged:UIAutomationCore.DLL)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]
UIA_RangeValueIsReadOnlyPropertyId :=True
UIA_RangeValueLargeChangePropertyId :=0
UIA_RangeValueMaximumPropertyId :=0
UIA_RangeValueMinimumPropertyId :=0
UIA_RangeValueSmallChangePropertyId :=0
UIA_RangeValueValuePropertyId :=0
UIA_RuntimeIdPropertyId :=42;2557468
UIA_ScrollHorizontallyScrollablePropertyId :=False
UIA_ScrollHorizontalScrollPercentPropertyId :=0
UIA_ScrollHorizontalViewSizePropertyId :=100
UIA_ScrollVerticallyScrollablePropertyId :=True
UIA_ScrollVerticalScrollPercentPropertyId :=0
UIA_ScrollVerticalViewSizePropertyId :=35.2941176470588
UIA_SelectionCanSelectMultiplePropertyId :=False
UIA_SelectionIsSelectionRequiredPropertyId :=False
UIA_SelectionselectionPropertyId :=
UIA_SelectionItemIsSelectedPropertyId :=False
UIA_SelectionItemSelectionContainerPropertyId :=
UIA_TableColumnHeadersPropertyId :=
UIA_TableItemColumnHeaderItemsPropertyId :=
UIA_TableRowHeadersPropertyId :=
UIA_TableRowOrColumnMajorPropertyId :=2
UIA_TableItemRowHeaderItemsPropertyId :=
UIA_ToggleToggleStatePropertyId :=2
UIA_TransformCanMovePropertyId :=False
UIA_TransformCanResizePropertyId :=False
UIA_TransformCanRotatePropertyId :=False
UIA_ValueIsReadOnlyPropertyId :=True
UIA_ValueValuePropertyId :=
UIA_WindowCanMaximizePropertyId :=False
UIA_WindowCanMinimizePropertyId :=False
UIA_WindowIsModalPropertyId :=False
UIA_WindowIsTopmostPropertyId :=False
UIA_WindowWindowInteractionStatePropertyId :=0
UIA_WindowWindowVisualStatePropertyId :=0

 

Thanks for taking a look!


I suck at programming... But I try really hard! :imwithstupid:

Share this post


Link to post
Share on other sites
junkew

take from the iuiautomation thread the latest simplespy (Work In Progress one, works fine) will give you some sourcecode direction on how to handle it.

please post that output. Output above of simplespy is of the older version giving you no information about parent hierarchy and giving no source code directions

Share this post


Link to post
Share on other sites
Yokes9

@Junkew,

Edit: deleted wrong information.

So right now I'm able to get the red box to go around each of my windows using the example give to me by the SimpleSpy. I'm still unsure of how to pull the data from the list.

The code that is allowing the red boxes to display around the windows and GXWND control. Not sure what is being returned with the Variables $oP0.

#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Logix Designer - LSI_400_Yokes in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - TEST];controltype:=UIA_WindowControlTypeId;class:=Afx:00100000:8:00010005:00000000:02EB144B", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=RSTrendX Properties;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Add/Configure Tags - TEST;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar("AvailableTags:.mainwindow","title:=AvailableTags:;classname:=GXWND")
_UIA_action("AvailableTags:.mainwindow","setfocus")

SimpleSpy Results

Mouse position is retrieved 710-460
At least we have an element [AvailableTags:][GXWND]
Having the following values for all properties: 
Title is: <AvailableTags:>  Class   := <GXWND>  controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    
*** Parent Information top down ***
3: Title is: <Desktop>  Class   := <#32769> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"   
2: Title is: <Logix Designer - LSI_400_Yokes in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - TEST]>    Class   := <Afx:00100000:8:00010005:00000000:02EB144B>  controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    
"Title:=Logix Designer - LSI_400_Yokes in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - TEST];controltype:=UIA_WindowControlTypeId;class:=Afx:00100000:8:00010005:00000000:02EB144B"    
1: Title is: <RSTrendX Properties>  Class   := <#32770> controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    
"Title:=RSTrendX Properties;controltype:=UIA_WindowControlTypeId;class:=#32770" 
0: Title is: <Add/Configure Tags - TEST>    Class   := <#32770> controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    
"Title:=Add/Configure Tags - TEST;controltype:=UIA_WindowControlTypeId;class:=#32770"   
*** Standard code ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Logix Designer - LSI_400_Yokes in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - TEST];controltype:=UIA_WindowControlTypeId;class:=Afx:00100000:8:00010005:00000000:02EB144B", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=RSTrendX Properties;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Add/Configure Tags - TEST;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar("AvailableTags:.mainwindow","title:=AvailableTags:;classname:=GXWND")
_UIA_action("AvailableTags:.mainwindow","setfocus")
*** Detailed properties of the highlighted element ***
UIA_title:= <AvailableTags:>
UIA_class:= <GXWND>
UIA_iaccessiblechildId:= <0>
UIA_RuntimeId:= <42;7147224>
UIA_BoundingRectangle:= <501;417;528;142>
; Main:Microsoft: MSAA Proxy (unmanaged:UIAutomationCore.DLL)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

Edited it to remove misinformation. Sorry.

Edit2: reading up on UI automation it seems I should be looking into dataTable it has been used for custom controls

Found here: http://uiautomation.codeplex.com/discussions/463334

Edited by Yokes9

I suck at programming... But I try really hard! :imwithstupid:

Share this post


Link to post
Share on other sites
Yokes9

Going to BUMP this once to see if anyone has any ideas. If not might have to abandon this project.


I suck at programming... But I try really hard! :imwithstupid:

Share this post


Link to post
Share on other sites
junkew

$p is a variable just an abbreviation in this case for parent(s) controls

see 

how to do this stuf step by step.

as you tried the simple spy code you say you get the rectangle around it

Then variable $p0 has normally the parent of your element and you should be able to get your listbox like

$myelement=_UIA_getObjectByFindAll($oP0, "title:=AvailableTags:;classname:=GXWND", $treescope_children)

from there on you can use what you have put in post1

;~*** Standard code ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Logix Designer - LSI_400_Yokes in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - TEST];controltype:=UIA_WindowControlTypeId;class:=Afx:00100000:8:00010005:00000000:02EB144B", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=RSTrendX Properties;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Add/Configure Tags - TEST;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)    
_UIA_Action($oP0,"setfocus")
_UIA_setVar("AvailableTags:.mainwindow","title:=AvailableTags:;classname:=GXWND")
_UIA_action("AvailableTags:.mainwindow","setfocus")

Share this post


Link to post
Share on other sites
Yokes9

Thanks for the help on this! I'll give that a try after the holiday! Really appreciate it!


I suck at programming... But I try really hard! :imwithstupid:

Share this post


Link to post
Share on other sites
Yokes9

So I tried this code:

#include "CUIAutomation2.au3"
Dim $oElementArray
Dim $myelement
Dim $iElements
HotKeySet("{Esc}", "captureEsc")


$hWnd = WinWaitActive("[CLASS:#32770]")
;~*** Standard code ***
#include "UIAWrappers.au3"
AutoItSetOption("MustDeclareVars", 1)

AutoItSetOption("MustDeclareVars", 1)

Local $oP2=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Logix Designer - LSI_400 in LSI_400_07_31_14.ACD [1756-L73 21.11]* - [Trend - Test];controltype:=UIA_WindowControlTypeId;class:=Afx:013D0000:8:00010005:00000000:0DFB1619", $treescope_children)
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=RSTrendX Properties;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=Add/Configure Tags - Test;controltype:=UIA_WindowControlTypeId;class:=#32770", $treescope_children)
_UIA_Action($oP0,"setfocus")
_UIA_setVar("AvailableTags:.mainwindow","title:=AvailableTags:;classname:=GXWND")
_UIA_action("AvailableTags:.mainwindow","setfocus")

$oElementArray=_UIA_getObjectByFindAll($oP0, "title:=AvailableTags:;classname:=GXWND", $treescope_children)
;_UIA_action($oElementArray,"click")

I can click on my box but can't seem to get to the next "level" and return anything within my element.

I also tried this:

MsgBox("", "", "Struct Size: " & DllStructGetSize($oElementArray) & @CRLF & _
            "Struct pointer: " & DllStructGetPtr($oElementArray) & @CRLF & _
            "Data:" & @CRLF & _
            DllStructGetData($oElementArray, 1) & @CRLF & _ ; Or "var1" instead of 1.
            DllStructGetData($oElementArray, "var2") & @CRLF & _ ; Or 2 instead of "var2".
            DllStructGetData($oElementArray, 3) & @CRLF & _ ; Or "var3" instead of 3.
            DllStructGetData($oElementArray, 4)) ; Or "var4" instead of 4.

    ; Release the resources used by the structure.
    $oElementArray = 0

This returned all "0"s but I'm not sure if that is because I'm doing this wrong. 

I will keep reading to see if I can get a better understanding but any further help would be appreciated.


I suck at programming... But I try really hard! :imwithstupid:

Share this post


Link to post
Share on other sites
junkew

quick start: /?do=embed' frameborder='0' data-embedContent>>/?do=embed' frameborder='0' data-embedContent>

Main thread: '?do=embed' frameborder='0' data-embedContent>>

If the spy does not get text / information UIA will not be the right technology to get your information

  • screenshot that shows your element is highlighted with simplespy
  • post output of simplespy with all properties
  • attached log.txt if available in your script directory
  • use allways contents of latest zip files which could be work in progress (WIP) zip

Share this post


Link to post
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
Sign in to follow this  

×