Jump to content

Control values keep changing randomly


DeeJay7
 Share

Recommended Posts

Below control values in my program (Service Manager client) is changing randomly time to time (mostly while close and open the program or tab)

  1. Instance
  2. ID:

There are no Text values for these controls in the program (as we can see in below example).

In below example, Instance: 2 and ID: 8525842 changes randomly.

>>>> Control <<<<Class: Edit
Instance: 2
ClassnameNN: Edit2
Name: 
Advanced (Class): [CLASS:Edit; INSTANCE:2]
ID: 8525842
Text: 
Position: 1198, 118
Size: 108, 20
ControlClick Coords: 37, 8
Style: 0x54010080
ExStyle: 0x00100000
Handle: 0x00821812
 
I need to send ControlSetText, ControlSend, ControlClick in my AU3 script.
I found few topics in the forum but couldn't get a solution for me.
Appreciate if you could help to get a solution.
Thanks.
Edited by DeeJay7
Link to comment
Share on other sites

No need to use the gui.  There is a services au3 UDF in the Example Scripts forum.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Simplespy output:

Mouse position is retrieved 1076-353
At least we have an element [][SWT_Window0]


Having the following values for all properties: 
Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 300;346;1038;870
*** Parent Information top down ***
10: Title is: <Desktop> Class   := <#32769> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 0;0;1366;768
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769" 
9: Title is: <HP Service Manager - Update Incident Number IN0003066540 - HP Service Manager Client> Class   := <SWT_Window0> controltype:= <UIA_WindowControlTypeId> ,<50032> , (0000C370) -8;-8;1379;754
"Title:=HP Service Manager - Update Incident Number IN0003066540 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0" 
8: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 28;68;1331;640
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
7: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 28;68;1331;640
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
6: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 296;68;1063;499
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
5: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
4: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
3: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
2: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 299;292;1057;272
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
1: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 300;317;1055;246
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
0: Title is: <> Class   := <SWT_Window0> controltype:= <UIA_PaneControlTypeId> ,<50033> , (0000C371) 300;317;1038;899
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 




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


Local $oP9=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=HP Service Manager - Update Incident Number IN0003066540 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP9,"setfocus")
Local $oP8=_UIA_getObjectByFindAll($oP9, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP8,"setfocus")
Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP7,"setfocus")
Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=SWT_Window0")
_UIA_action(".mainwindow","setfocus")




*** Detailed properties of the highlighted element ***
UIA_class:= <SWT_Window0>
UIA_regexpclass:= <SWT_Window0>
UIA_iaccessiblechildId:= <0>
UIA_id:= <4199288>
UIA_handle:= <4199288>
UIA_RuntimeId:= <42;4199288>
UIA_BoundingRectangle:= <300;346;1038;870>
UIA_ProcessId:= <7856>
UIA_ControlType:= <50033>
UIA_LocalizedControlType:= <pane>
UIA_HasKeyboardFocus:= <False>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <4199288>
UIA_ClassName:= <SWT_Window0>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <4199288>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <False>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueIsReadOnly:= <True>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleRole:= <10>
UIA_LegacyIAccessibleState:= <1048576>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:6528,hwnd:0x401378 Main:Nested [pid:7856,hwnd:0x401378 Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>
Edited by DeeJay7
Link to comment
Share on other sites

interesting. Its not revealing much of the controls regarding information.

What happens if you use simple spy and hover over different controls and you press ctrl+w. Will it highlight all small controls or only the whole pane.

If its allways the whole window it will not reveal much more but it looks like the parent windows are telling the rectangles
 

However when it highlights your smaller textcontrols you can get information with syntax like

_UIA_setVar("myTextbox","title:=;classname:=SWT_Window0;index:=nn")
_UIA_Action("myTextbox","getvalue")

I think I did forget to build command like below but can be done as I think getvalue will not help you further

getvalue using keys (Ctrl+c, Ctrl+v logic to a variable)
Link to comment
Share on other sites

junkew, I can confirm Ctrl+W highlights small control only (not whole window), attached below is the latest simplespy output. Please have a look and reply if we have any luck.

Also when I press Ctrl+R, I'm getting AutoIt error Line 229 : Subscript used on non-accessible variable - (may not be related though).

Thanks.

Mouse position is retrieved 1239-370
At least we have an element [][Edit]

Having the following values for all properties: 
Title is: <>    Class   := <Edit>   controltype:= <UIA_EditControlTypeId>   ,<50004>    , (0000C354)    1198;358;108;20
*** Parent Information top down ***
12: Title is: <Desktop> Class   := <#32769> controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    0;0;1366;768
"Title:=Desktop;controltype:=UIA_PaneControlTypeId;class:=#32769"   
11: Title is: <HP Service Manager - Update Incident Number IM0003067091 - HP Service Manager Client>    Class   := <SWT_Window0>    controltype:= <UIA_WindowControlTypeId> ,<50032>    , (0000C370)    -8;-8;1379;754
"Title:=HP Service Manager - Update Incident Number IM0003067091 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0"   
10: Title is: <>    Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    28;68;1331;640
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
9: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    28;68;1331;640
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
8: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    296;68;1063;499
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
7: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
6: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
5: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    299;94;1057;470
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
4: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    299;292;1057;272
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
3: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    300;317;1055;246
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
2: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    300;317;1038;899
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
1: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    300;346;1038;870
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 
0: Title is: <> Class   := <SWT_Window0>    controltype:= <UIA_PaneControlTypeId>   ,<50033>    , (0000C371)    1196;356;132;24
"Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0" 


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

Local $oP11=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=HP Service Manager - Update Incident Number IM0003067091 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP11,"setfocus")
Local $oP10=_UIA_getObjectByFindAll($oP11, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)    
_UIA_Action($oP10,"setfocus")
Local $oP9=_UIA_getObjectByFindAll($oP10, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP9,"setfocus")
Local $oP8=_UIA_getObjectByFindAll($oP9, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP8,"setfocus")
Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP7,"setfocus")
Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Edit")
_UIA_action(".mainwindow","setfocus")


*** Detailed properties of the highlighted element ***
UIA_class:= <Edit>
UIA_regexpclass:= <Edit>
UIA_iaccessiblevalue:= <Open>
UIA_iaccessiblechildId:= <0>
UIA_id:= <9903306>
UIA_handle:= <9903306>
UIA_RuntimeId:= <42;9903306>
UIA_BoundingRectangle:= <1198;358;108;20>
UIA_ProcessId:= <3748>
UIA_ControlType:= <50004>
UIA_LocalizedControlType:= <edit>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <9903306>
UIA_ClassName:= <Edit>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <9903306>
UIA_IsOffscreen:= <False>
UIA_Orientation:= <0>
UIA_FrameworkId:= <Win32>
UIA_IsRequiredForForm:= <False>
UIA_IsDockPatternAvailable:= <False>
UIA_IsExpandCollapsePatternAvailable:= <False>
UIA_IsGridItemPatternAvailable:= <False>
UIA_IsGridPatternAvailable:= <False>
UIA_IsInvokePatternAvailable:= <False>
UIA_IsMultipleViewPatternAvailable:= <False>
UIA_IsRangeValuePatternAvailable:= <False>
UIA_IsScrollPatternAvailable:= <False>
UIA_IsScrollItemPatternAvailable:= <False>
UIA_IsSelectionItemPatternAvailable:= <False>
UIA_IsSelectionPatternAvailable:= <False>
UIA_IsTablePatternAvailable:= <False>
UIA_IsTableItemPatternAvailable:= <False>
UIA_IsTextPatternAvailable:= <False>
UIA_IsTogglePatternAvailable:= <False>
UIA_IsTransformPatternAvailable:= <False>
UIA_IsValuePatternAvailable:= <True>
UIA_IsWindowPatternAvailable:= <False>
UIA_ValueValue:= <Open>
UIA_ValueIsReadOnly:= <False>
UIA_RangeValueValue:= <0>
UIA_RangeValueIsReadOnly:= <True>
UIA_RangeValueMinimum:= <0>
UIA_RangeValueMaximum:= <0>
UIA_RangeValueLargeChange:= <0>
UIA_RangeValueSmallChange:= <0>
UIA_ScrollHorizontalScrollPercent:= <0>
UIA_ScrollHorizontalViewSize:= <100>
UIA_ScrollVerticalScrollPercent:= <0>
UIA_ScrollVerticalViewSize:= <100>
UIA_ScrollHorizontallyScrollable:= <False>
UIA_ScrollVerticallyScrollable:= <False>
UIA_SelectionCanSelectMultiple:= <False>
UIA_SelectionIsSelectionRequired:= <False>
UIA_GridRowCount:= <0>
UIA_GridColumnCount:= <0>
UIA_GridItemRow:= <0>
UIA_GridItemColumn:= <0>
UIA_GridItemRowSpan:= <1>
UIA_GridItemColumnSpan:= <1>
UIA_DockDockPosition:= <5>
UIA_ExpandCollapseExpandCollapseState:= <3>
UIA_MultipleViewCurrentView:= <0>
UIA_WindowCanMaximize:= <False>
UIA_WindowCanMinimize:= <False>
UIA_WindowWindowVisualState:= <0>
UIA_WindowWindowInteractionState:= <0>
UIA_WindowIsModal:= <False>
UIA_WindowIsTopmost:= <False>
UIA_SelectionItemIsSelected:= <False>
UIA_TableRowOrColumnMajor:= <2>
UIA_ToggleToggleState:= <2>
UIA_TransformCanMove:= <False>
UIA_TransformCanResize:= <False>
UIA_TransformCanRotate:= <False>
UIA_IsLegacyIAccessiblePatternAvailable:= <True>
UIA_LegacyIAccessibleChildId:= <0>
UIA_LegacyIAccessibleValue:= <Open>
UIA_LegacyIAccessibleRole:= <42>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:9876,hwnd:0x971CCA Main:Nested [pid:3748,hwnd:0x971CCA Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]>
UIA_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

post-88822-0-20479300-1417529451_thumb.p

Link to comment
Share on other sites

Not yet, will do shortly. thx.

 

Did you test the suggestion in post #8?

Danp2, X & Y values didn't work, but Width and Height values worked. Understood W & H cannot be reliable as there may be multiple boxes with same size.

Later I found the weird thing that even X, Y, W, H values keep changing. :sweating:

In my multiple tries, found below values only stay without change:

>>>> Control <<<<
Class:  Edit

Style:  0x54010080
ExStyle:    0x00100000


>>>> Mouse <<<<

Color:  0xFFFFFF

Is there any possibility to send controls and texts to above values?

In the meantime I'm checking junkew's iuiautomation thread.

Thanks.

Link to comment
Share on other sites

Is there anything nearby that you can use?

Maybe a label, or a parent control (one that wraps around yours...like a button 'grouping').

Then, you can look relative to those, rather than the whole window...or, check out my signature to grab all the controls...if you provide the output, maybe we can find other ways to grab it, consistently.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

the spy gave you this did you try to run it? Do not think it will run usefull as parenthierarchy of your controls seems not to be registering natively
 

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

Local $oP11=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=HP Service Manager - Update Incident Number IM0003067091 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP11,"setfocus")
Local $oP10=_UIA_getObjectByFindAll($oP11, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)    
_UIA_Action($oP10,"setfocus")
Local $oP9=_UIA_getObjectByFindAll($oP10, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP9,"setfocus")
Local $oP8=_UIA_getObjectByFindAll($oP9, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP8,"setfocus")
Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP7,"setfocus")
Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Edit")
_UIA_action(".mainwindow","setfocus")

Simplified something like this could work (but slow this way so first make sure parentwindow gets focus)
 

_UIA_setVar("myOpenTexBox","title:=;classname:=Edit;iAccessibleValue=Open") 

_UIA_action("myOpenTextBox","setfocus")
$myVar=_UIA_action("myOpenTextbox","getValue")

 


you have luck I implemented getValue with a select all and copy to clipboard logic like this (and not using IUIautomation patterns to getvalue, not reliable on many controls)

case "getValue"
$obj2ActOn.setfocus()
Send("^a")
Send("^c")
$retValue=clipget()

But to resolve your issue it looks like you have to modify simplespy to work with the iAccessibleValue property to identify
 
Change and add this area of simplespy code with the lines I underlined

;~ parentcount-1 As thats the $UIA_oDesktop
    for $i=$parentcount to 0 step -1
            $objParent=$oParentHandle[$i]
            local $ptitle=_UIA_getPropertyValue($objParent,$UIA_NamePropertyId)
            local $pclass=_UIA_getPropertyValue($objParent,$uia_classnamepropertyid)

local $pIAccessibleValue=_UIA_getPropertyValue($objParent,$UIA_LegacyIAccessibleValuePropertyId)

local $pcontroltypeName=_UIA_getControlName(_UIA_getPropertyValue($objParent,$UIA_ControlTypePropertyId))
            local $pControltypeId=_UIA_getPropertyValue($objParent,$UIA_ControlTypePropertyId)

; local $pDefaultExpression="""Title:=" & $pTitle & ";" & "controltype:=" & $pControlTypeName & ";" & "class:=" & $pClass & """"
local $pDefaultExpression="""Title:=" & $pTitle & ";" & "controltype:=" & $pControlTypeName & ";" & "class:=" & $pClass & ";" & "iAccessibleValue:=" & $pIAccessibleValue & """"

local $pNativeWindow=_UIA_getPropertyValue($objParent, $UIA_NativeWindowHandlePropertyId)
            local $pcontrolRect=_UIA_getPropertyValue($objParent, $UIA_BoundingRectanglePropertyId)

            $ptext1=$pText1 & $I & ": Title is: <" &  $ptitle &  ">" & @TAB _
                    & "Class   := <" & $pclass &  ">" & @TAB _
                    & "controltype:= " & "<" &  $pcontroltypeName &  ">" & @TAB  _
                    & ",<" &  $PcontroltypeId &  ">" & @TAB & ", (" &  hex($PcontroltypeId) &  ")" & @TAB &  $pcontrolRect  & @CRLF
            $ptext1=$ptext1 &  $pdefaultExpression & @TAB & @CRLF
            if $i=$parentcount-1 Then
                $pCodeText2=$pCodeText2 & "Local $oP" &$i & "=_UIA_getObjectByFindAll($UIA_oDesktop, " & $pdefaultExpression & ", $treescope_children)" & @TAB & @CRLF
            Else
                if $i<=$parentcount-2 then
                    $pCodeText2=$pCodeText2 & "Local $oP" &$i & "=_UIA_getObjectByFindAll($oP" & $i+1 & ", " & $pdefaultExpression & ", $treescope_children)" & @TAB & @CRLF

                endif

            endif
            if ($pnativeWindow <> 0) and ($i<>$ParentCount) Then
                $pCodeText2=$pCodeText2 & "_UIA_Action($oP" & $i & ",""setfocus"")"  & @CRLF
            endif
    Next

and if all above is not working only instance/index counting will work but sometimes this is hard and most likely you need 

_UIA_DumpThemAll($oStart, $treescope_subtree)

or / and inspect.exe as can be found in windows sdk (then you have to count the index manually)
So try this when indexing is needed

_UIA_action("classname:=Edit;index:=1","setfocus")

and variations on above are those 2 properties

  • indexrelative:=nn
    use this when you can identify another object with a title/name as thats more stable and then use +nn or -nn to just count forward/backward number of related elements
  • instance:=nn (=synonym for index, same behavior just different syntax)
Edited by junkew
Link to comment
Share on other sites

 

the spy gave you this did you try to run it? Do not think it will run usefull as parenthierarchy of your controls seems not to be registering natively

 

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

Local $oP11=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=HP Service Manager - Update Incident Number IM0003067091 - HP Service Manager Client;controltype:=UIA_WindowControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP11,"setfocus")
Local $oP10=_UIA_getObjectByFindAll($oP11, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)    
_UIA_Action($oP10,"setfocus")
Local $oP9=_UIA_getObjectByFindAll($oP10, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children) 
_UIA_Action($oP9,"setfocus")
Local $oP8=_UIA_getObjectByFindAll($oP9, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP8,"setfocus")
Local $oP7=_UIA_getObjectByFindAll($oP8, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP7,"setfocus")
Local $oP6=_UIA_getObjectByFindAll($oP7, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP6,"setfocus")
Local $oP5=_UIA_getObjectByFindAll($oP6, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=SWT_Window0", $treescope_children)  
_UIA_Action($oP0,"setfocus")
_UIA_setVar(".mainwindow","title:=;classname:=Edit")
_UIA_action(".mainwindow","setfocus")

Simplified something like this could work (but slow this way so first make sure parentwindow gets focus)

 

_UIA_setVar("myOpenTexBox","title:=;classname:=Edit;iAccessibleValue=Open") 

_UIA_action("myOpenTextBox","setfocus")
$myVar=_UIA_action("myOpenTextbox","getValue")

 

you have luck I implemented getValue with a select all and copy to clipboard logic like this (and not using IUIautomation patterns to getvalue, not reliable on many controls)

case "getValue"
$obj2ActOn.setfocus()
Send("^a")
Send("^c")
$retValue=clipget()

But to resolve your issue it looks like you have to modify simplespy to work with the iAccessibleValue property to identify

 

Change and add this area of simplespy code with the lines I underlined

;~ parentcount-1 As thats the $UIA_oDesktop
    for $i=$parentcount to 0 step -1
            $objParent=$oParentHandle[$i]
            local $ptitle=_UIA_getPropertyValue($objParent,$UIA_NamePropertyId)
            local $pclass=_UIA_getPropertyValue($objParent,$uia_classnamepropertyid)

local $pIAccessibleValue=_UIA_getPropertyValue($objParent,$UIA_LegacyIAccessibleValuePropertyId)

local $pcontroltypeName=_UIA_getControlName(_UIA_getPropertyValue($objParent,$UIA_ControlTypePropertyId))
            local $pControltypeId=_UIA_getPropertyValue($objParent,$UIA_ControlTypePropertyId)

; local $pDefaultExpression="""Title:=" & $pTitle & ";" & "controltype:=" & $pControlTypeName & ";" & "class:=" & $pClass & """"

local $pDefaultExpression="""Title:=" & $pTitle & ";" & "controltype:=" & $pControlTypeName & ";" & "class:=" & $pClass & ";" & "iAccessibleValue:=" & $pIAccessibleValue & """"

local $pNativeWindow=_UIA_getPropertyValue($objParent, $UIA_NativeWindowHandlePropertyId)
            local $pcontrolRect=_UIA_getPropertyValue($objParent, $UIA_BoundingRectanglePropertyId)

            $ptext1=$pText1 & $I & ": Title is: <" &  $ptitle &  ">" & @TAB _
                    & "Class   := <" & $pclass &  ">" & @TAB _
                    & "controltype:= " & "<" &  $pcontroltypeName &  ">" & @TAB  _
                    & ",<" &  $PcontroltypeId &  ">" & @TAB & ", (" &  hex($PcontroltypeId) &  ")" & @TAB &  $pcontrolRect  & @CRLF
            $ptext1=$ptext1 &  $pdefaultExpression & @TAB & @CRLF
            if $i=$parentcount-1 Then
                $pCodeText2=$pCodeText2 & "Local $oP" &$i & "=_UIA_getObjectByFindAll($UIA_oDesktop, " & $pdefaultExpression & ", $treescope_children)" & @TAB & @CRLF
            Else
                if $i<=$parentcount-2 then
                    $pCodeText2=$pCodeText2 & "Local $oP" &$i & "=_UIA_getObjectByFindAll($oP" & $i+1 & ", " & $pdefaultExpression & ", $treescope_children)" & @TAB & @CRLF

                endif

            endif
            if ($pnativeWindow <> 0) and ($i<>$ParentCount) Then
                $pCodeText2=$pCodeText2 & "_UIA_Action($oP" & $i & ",""setfocus"")"  & @CRLF
            endif
    Next

and if all above is not working only instance/index counting will work but sometimes this is hard and most likely you need 

_UIA_DumpThemAll($oStart, $treescope_subtree)

or / and inspect.exe as can be found in windows sdk (then you have to count the index manually)

So try this when indexing is needed

_UIA_action("classname:=Edit;index:=1","setfocus")

and variations on above are those 2 properties

  •  
  • indexrelative:=nn

    use this when you can identify another object with a title/name as thats more stable and then use +nn or -nn to just count forward/backward number of related elements

  • instance:=nn (=synonym for index, same behavior just different syntax)

 

Thanks, I'll try this and will come back.

Link to comment
Share on other sites

Is there anything nearby that you can use?

 

Maybe a label, or a parent control (one that wraps around yours...like a button 'grouping').

 

Then, you can look relative to those, rather than the whole window...or, check out my signature to grab all the controls...if you provide the output, maybe we can find other ways to grab it, consistently.

Hi jdelaney,

I've attached output of GetAllWindowControls. Please have a look and let me know if any luck.

Func=[GetAllWindowsControls]: ControlCounter=[308] ControlID=[10689542] Handle=[0x00A31C06] ClassNN=[             Edit21] XPos=[-165] YPos=[-123] Width=[   0] Height=[   0] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[309] ControlID=[9637224] Handle=[0x00930D68] ClassNN=[             Edit22] XPos=[-165] YPos=[-123] Width=[   0] Height=[   0] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[310] ControlID=[4588390] Handle=[0x00460366] ClassNN=[             Edit23] XPos=[-165] YPos=[-123] Width=[   0] Height=[   0] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[311] ControlID=[10819010] Handle=[0x00A515C2] ClassNN=[             Edit24] XPos=[-165] YPos=[-123] Width=[   0] Height=[   0] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[312] ControlID=[9637276] Handle=[0x00930D9C] ClassNN=[             Edit25] XPos=[-165] YPos=[-123] Width=[   0] Height=[   0] IsVisible=[0] Text=[INM25931039].
Func=[GetAllWindowsControls]: ControlCounter=[313] ControlID=[11672174] Handle=[0x00B21A6E] ClassNN=[             Edit26] XPos=[ 191] YPos=[ 118] Width=[ 341] Height=[  20] IsVisible=[1] Text=[IM0003069585].
Func=[GetAllWindowsControls]: ControlCounter=[314] ControlID=[14095378] Handle=[0x00D71412] ClassNN=[             Edit27] XPos=[1164] YPos=[ 118] Width=[ 142] Height=[  20] IsVisible=[1] Text=[Open].
Func=[GetAllWindowsControls]: ControlCounter=[315] ControlID=[15929656] Handle=[0x00F31138] ClassNN=[             Edit28] XPos=[ 191] YPos=[ 142] Width=[ 217] Height=[  20] IsVisible=[1] Text=[NONE].
Func=[GetAllWindowsControls]: ControlCounter=[316] ControlID=[1976428] Handle=[0x001E286C] ClassNN=[             Edit29] XPos=[ 605] YPos=[ 142] Width=[ 134] Height=[  20] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[317] ControlID=[10034602] Handle=[0x00991DAA] ClassNN=[             Edit30] XPos=[ 860] YPos=[ 142] Width=[ 141] Height=[  20] IsVisible=[0] Text=[].
Func=[GetAllWindowsControls]: ControlCounter=[318] ControlID=[798382] Handle=[0x000C2EAE] ClassNN=[             Edit31] XPos=[1164] YPos=[ 142] Width=[ 142] Height=[  20] IsVisible=[1] Text=[16/12/14 21:00:00].

How can I send control to Edit27 of above output? Please note that text value in Edit27 (Open) is not permanent.

Repeating below the line of Edit27:

Func=[GetAllWindowsControls]: ControlCounter=[314] ControlID=[14095378] Handle=[0x00D71412] ClassNN=[Edit27] XPos=[1164] YPos=[ 118] Width=[ 142] Height=[  20] IsVisible=[1] Text=[Open].

 

Thanks.

Link to comment
Share on other sites

Well, one way is to loop through all of them until you can hit a regexp that matches the date field...when it's empty, does it still include place holder digits?

If you output the Labels also, it would probably be a better route...get that label (which will have known text), and then find the edit nearest it to the right.

The function also accepts some parameters.  You an turn off output of non-visible controls, which will help you reduce the amount of controls you have to check.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
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...