Jump to content

Problem returning Windows form textbox contents to AutoIT - (Moved)


 Share

Recommended Posts

I am having a tough time trying to determine if I need ControlGetText or another function to return to my running script, the value in a text box in a form in a running Windows application.

The control has no name and I have attempted to use the extended control method including what is available for the text box on the form; all to no avail.

I realize there is a lot of trial and error here, but am I heading down the right path? Do I need to do a ControlSetText first (pretty sure I tried that to no avail.)

Thank you.

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

There were multiple attempts (mostly commented out in the attached). I am getting the handle returned but pretty sure something(s)  additional is missing here.

I have clawed and scraped (ok not literally) through the navigation of three (3) separate Windows form to get to this one where I need to potentially modify an accounts address with a new one I have in an Excel file (reading this file already working too). This includes one form where I paste the contents of one Excel cell to a form and click on a radio  button.

Thank you in advance.

Go_Next_20180628_004.au3

AutoIT snip_20180628.PNG

Edited by JPQ
Further notees
Link to comment
Share on other sites

Pass on downloading files from non-trusted sources.

use the ID: 1031

$hWin = WinGetHandle("Edit Patient Information")
If Not IsHWnd($hWin) Then
    ConsoleWrite("WinGetHandle failed to find a window" & @CRLF)
    Exit
EndIf
ConsoleWrite("$hWin=" & $hWin & @CRLF)

$hControl = ControlGetHandle($hWin,"",1031)
If Not IsHWnd($hControl) Then
    ConsoleWrite("ControlGetHandle failed to find control")
    Exit
EndIf
ConsoleWrite("$hControl=" & $hControl & @CRLF)

$sText = ControlGetText($hWin,"",$hControl)
ConsoleWrite("$sText=" & $sText & @CRLF)

 

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

So I have been able to get the handle of the Window (after researching and found I would need to use Opt("WinTitleMatchMode", 4) but now I'm unable to get the handle of the particular control on the form whose handle I just successfully retrieved.

The parameters I am using for the individual control seem to change every time I open this form. I think I may have to loop through all the controls on this form (which may be a child form in itself) to see if there's any other way to consistently reference this and all the other controls (all text boxes) I need to access.

Having consulted with a Windows forms developer on my work team, it appears these controls are being somewhat reused, thus causing the Instance #'s for instance to change.

Can someone point me to the proper function to be able to list out all child elements?

 

Link to comment
Share on other sites

You can use my signature as an example of looping through all controls in a window.  I'm doubtful that the id will change.   fyi, developing on instance based counters will break evetime a new control is added or removed.   I'd suggest not doing that.

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

So i downloaded the simplespy.au3 script from elsewhere on the AutoIT website, and ran this against one of the text boxes on the form that I m trying to "read" from. I am attaching the results of that here. 

Based on what you can have the time to review here, would you (in your opinion) further attempt to complete a script where I am reviewing any/all address related text boxes against an Excel file which has potentially new/changed addresses. I may have to revisit this later and take on a less onerous multi-form, multi-click scenario,

It would be a shame but eventually I will have to move on. BTW: The contents of the address field in the attached is found here "UIA_iaccessiblevalue:= <1521 N 1350 W>".

Thank you for your help and honest feedback.

new Spy Report_20180702.txt

Link to comment
Share on other sites

Here you go:

 

    https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/?do=findComment&comment=1156373
At least we have an element title: [] class: [Edit]

Having the following values for all properties: 
 

Title is: <>    Class   := <Edit>    controltype:= <UIA_EditControlTypeId>    ,<50004>    , (0000C354)    345;392;160;18
*** Parent Information top down ***
5: Title is: <Intergy - Aegis Sciences Corporation - User Name>    Class   := <WindowsForms10.Window.8.app.0.1d2098a_r46_ad1>    controltype:= <UIA_WindowControlTypeId>    ,<50032>    , (0000C370)    0;0;1359;688
"Title:=Intergy - Aegis Sciences Corporation - User Name;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1""    
4: Title is: <>    Class   := <WindowsForms10.Window.8.app.0.1d2098a_r46_ad1>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    8;86;1343;594
"Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1""    
3: Title is: <Edit Patient Information>    Class   := <ProMainWin>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    288;174;783;456
"Title:=Edit Patient Information;controltype:=UIA_PaneControlTypeId;class:=ProMainWin""    
2: Title is: <>    Class   := <ProClientWin>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    291;219;777;408
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ProClientWin""    
1: Title is: <>    Class   := <ProFrame>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    291;219;777;408
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame""    
0: Title is: <>    Class   := <ProFrame>    controltype:= <UIA_PaneControlTypeId>    ,<50033>    , (0000C371)    294;225;673;399
"Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame""    

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

_UIA_setVar("oP1","Title:=Intergy - Aegis Sciences Corporation - User Name;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1")    ;Intergy - Aegis Sciences Corporation - User Name
_UIA_setVar("oP2","Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1")    ;
_UIA_setVar("oP3","Title:=Edit Patient Information;controltype:=UIA_PaneControlTypeId;class:=ProMainWin")    ;Edit Patient Information
_UIA_setVar("oP4","Title:=;controltype:=UIA_PaneControlTypeId;class:=ProClientWin")    ;
_UIA_setVar("oP5","Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame")    ;
_UIA_setVar("oP6","Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame")    ;

_UIA_setVar(".mainwindow","title:=;classname:=Edit")

;~ Actions split away from logical/technical definition above can come from configfiles 

;~_UIA_Action("oP1","highlight")
_UIA_Action("oP1","setfocus")
;~_UIA_Action("oP2","highlight")
_UIA_Action("oP2","setfocus")
;~_UIA_Action("oP3","highlight")
_UIA_Action("oP3","setfocus")
;~_UIA_Action("oP4","highlight")
_UIA_Action("oP4","setfocus")
;~_UIA_Action("oP5","highlight")
_UIA_Action("oP5","setfocus")
;~_UIA_Action("oP6","highlight")
_UIA_Action("oP6","setfocus")

_UIA_action(".mainwindow","setfocus")


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

Local $oP5=_UIA_getObjectByFindAll($UIA_oDesktop, "Title:=Intergy - Aegis Sciences Corporation - User Name;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1", $treescope_children)    
_UIA_Action($oP5,"setfocus")
Local $oP4=_UIA_getObjectByFindAll($oP5, "Title:=;controltype:=UIA_PaneControlTypeId;class:=WindowsForms10.Window.8.app.0.1d2098a_r46_ad1", $treescope_children)    
_UIA_Action($oP4,"setfocus")
Local $oP3=_UIA_getObjectByFindAll($oP4, "Title:=Edit Patient Information;controltype:=UIA_PaneControlTypeId;class:=ProMainWin", $treescope_children)    
_UIA_Action($oP3,"setfocus")
Local $oP2=_UIA_getObjectByFindAll($oP3, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ProClientWin", $treescope_children)    
_UIA_Action($oP2,"setfocus")
Local $oP1=_UIA_getObjectByFindAll($oP2, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame", $treescope_children)    
_UIA_Action($oP1,"setfocus")
Local $oP0=_UIA_getObjectByFindAll($oP1, "Title:=;controltype:=UIA_PaneControlTypeId;class:=ProFrame", $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:= <1521 N 1350 W>
UIA_iaccessiblechildId:= <0>
UIA_id:= <213>
UIA_handle:= <658108>
UIA_RuntimeId:= <42;658108>
UIA_BoundingRectangle:= <345;392;160;18>
UIA_ProcessId:= <4828>
UIA_ControlType:= <50004>
UIA_LocalizedControlType:= <edit>
UIA_HasKeyboardFocus:= <True>
UIA_IsKeyboardFocusable:= <True>
UIA_IsEnabled:= <True>
UIA_AutomationId:= <213>
UIA_ClassName:= <Edit>
UIA_Culture:= <0>
UIA_IsControlElement:= <True>
UIA_IsContentElement:= <True>
UIA_IsPassword:= <False>
UIA_NativeWindowHandle:= <658108>
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:= <1521 N 1350 W>
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:= <1521 N 1350 W>
UIA_LegacyIAccessibleRole:= <42>
UIA_LegacyIAccessibleState:= <1048580>
UIA_IsDataValidForForm:= <False>
UIA_ProviderDescription:= <[pid:3176,hwnd:0xA0ABC Main:Nested [pid:4828,hwnd:0xA0ABC 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_IsItemContainerPatternAvailable:= <False>
UIA_IsVirtualizedItemPatternAvailable:= <False>
UIA_IsSynchronizedInputPatternAvailable:= <False>

 

Edited by JLogan3o13
Link to comment
Share on other sites

Oh, that's uia...just use the spytool that comes with autoit or my signature function. ..uia is the last resort for when standard functions don't apply (my opinion)

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...