Jump to content
Sign in to follow this  
azcn2503

Problem manipulating a WinForms application

Recommended Posts

azcn2503

Hello,

I am trying to automate an installer package and I am facing some significant difficulties when getting to a part of the installation that uses WinForms controls. I am able to retrieve the window handle using WinGetHandle, and I can get control handles using ControlGetHandle. I cannot get the window position, move the window, focus, click, or otherwise manipulate any of the controls.

When I use the window information tool, it shows all the information for the controls, but if I try to use one of them, it is as if nothing is happening.

Here is some sample code and the console output from the code:

WinActivate("Site Setup")

$wHandle = WinGetHandle("Site Setup")
ConsoleWrite("wHandle: " & $wHandle & @LF)

$wPos = WinGetPos($wHandle)
ConsoleWrite("wPos: " & $wPos & @LF)

$cHandle = ControlGetHandle($wHandle, "", "[CLASS:WindowsForms10.EDIT.app.0.2bf8098_r11_ad1; INSTANCE:3]")
ConsoleWrite("cHandle: " & $cHandle & @LF)

$cText = ControlGetText($wHandle, "", $cHandle)
ConsoleWrite("cText: " & $cText & @LF)

ControlSetText($wHandle, "", $cHandle, "80")

$cText = ControlGetText($wHandle, "", $cHandle)
ConsoleWrite("cText: " & $cText & @LF)

$cPos = ControlGetPos($wHandle, "", $cHandle)
ConsoleWrite("cPos: " & $cPos & @LF)
wHandle: 0x00070E8E
wPos: 
cHandle: 0x00051072
cText: 85
cText: 85
cPos:

Any ideas on how I can get this to work?

Many thanks in advance.

Share this post


Link to post
Share on other sites
azcn2503

Thanks for the link. I've downloaded this IUIAutomation tool but I haven't the first idea where to begin, or which part of the tutorials apply to my issue. Perhaps somebody could provide some guidance?

Additionally - simplespy.au3 crashes immediately whenever I try to get information from the WinForms application using Ctrl+W.

I don't think the issue is with finding out the names of the controls, their class, name, etc. as AutoIt can see this already. But perhaps I am mistaken.

Edited by azcn2503

Share this post


Link to post
Share on other sites
November

Working fine with me!

Did you get all  files from UIA_V0_4.zip file included in thread?

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
azcn2503

I did yes.

It seems to work in any other application, but when I use it in the WinForms application I am trying to manipulate, the simplespy app crashes.

Share this post


Link to post
Share on other sites
junkew

Which platform are you using 32 or 64 bits, win7 or win8. I know in the CUIAutomation.AU3 I have some misdefinitions on lengths/parameters that are used.

However never observed crashing. If you have Windows SDK installed you have tool inspect.exe. Would be interesting to know what inspect.exe gives on the controls you try of winforms.

Share this post


Link to post
Share on other sites
azcn2503

I am using Windows 8.0 Enterprise 64-bit.

I just downloaded and installed the Windows SDK for Windows 8 and ran inspect.exe, which reveals the following information on the control when I hover it:

How found:  Mouse move (582,259)
    hwnd=0x0000000000040786 64bit class="WindowsForms10.EDIT.app.0.2bf8098_r11_ad1" style=0x560100C0 ex=0x0
Name:   "Port:"
ControlType:    UIA_EditControlTypeId (0xC354)
LocalizedControlType:   "edit"
BoundingRectangle:  {l:556 t:255 r:601 b:271}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AccessKey:  ""
ProcessId:  5080
RuntimeId:  [2A.40786]
AutomationId:   "264070"
FrameworkId:    "WinForm"
ClassName:  "WindowsForms10.EDIT.app.0.2bf8098_r11_ad1"
NativeWindowHandle: 0x40786
ProviderDescription:    "[pid:8628,hwnd:0x40786 Main:Nested [pid:5080,hwnd:0x40786 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText:   ""
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Port:"
LegacyIAccessible.Role: editable text (0x2A)
LegacyIAccessible.State:    focusable (0x100000)
LegacyIAccessible.Value:    "85"
Value.IsReadOnly:   false
Value.Value:    "85"
IsAnnotationPatternAvailable:   false
IsDragPatternAvailable: false
IsDockPatternAvailable: false
IsDropTargetPatternAvailable:   false
IsExpandCollapsePatternAvailable:   false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable:   false
IsItemContainerPatternAvailable:    false
IsLegacyIAccessiblePatternAvailable:    true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable:  false
IsRangeValuePatternAvailable:   false
IsScrollItemPatternAvailable:   false
IsScrollPatternAvailable:   false
IsSelectionItemPatternAvailable:    false
IsSelectionPatternAvailable:    false
IsSpreadsheetItemPatternAvailable:  false
IsSpreadsheetPatternAvailable:  false
IsStylesPatternAvailable:   false
IsSynchronizedInputPatternAvailable:    false
IsTableItemPatternAvailable:    false
IsTablePatternAvailable:    false
IsTextChildPatternAvailable:    false
IsTextPatternAvailable: false
IsTextPattern2Available:    false
IsTogglePatternAvailable:   false
IsTransformPatternAvailable:    false
IsTransform2PatternAvailable:   false
IsValuePatternAvailable:    true
IsVirtualizedItemPatternAvailable:  false
IsWindowPatternAvailable:   false
FirstChild: [null]
LastChild:  [null]
Next:   [null]
Previous:   "Spinner" spinner
Other Props:    Object has no additional properties
Children:   Container has no children
Ancestors:  "Port:" combo box
    "" pane
    "IIS configuration" group
    "" pane
    "Site Setup" window
    "Desktop" pane
    [ No Parent ]

Share this post


Link to post
Share on other sites
junkew

ok it at least gives proof with IUIAutomation you can automate your controls.

Unfortunately I do not have Win8 64 bits version to test on but I am relatively sure this has to do with the definitions in CUIAUTOMATION2.AU3 which can / have to be sometimes different for 32/64 win7 and win8.

Hard to fix for me as long as I cannot reproduce.

Share this post


Link to post
Share on other sites
azcn2503

Would you suggest I use another OS? I can use a virtual environment to try to get this to work, but I think that in the production environment we are going to use Windows Server 2012. Will I have better luck on the server?

Update: I have tried using White UI automation with some C# code, and although it can attach to the process, find the window, bring it to focus, etc. it cannot in any way make changes to the elements. In fact, just getting elements by their automation ID does not work with White.

Sample code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestStack.White;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;

namespace WhiteAutomation
{
    class Program
    {
        static void Main(string[] args)
        {
            var app = Application.Attach("IntelliSearch.EspClientSetup");
            var window = app.GetWindow("Site Setup");
            window.Focus();
            var edit = window.Get<TextBox>(SearchCriteria.ByAutomationId("395230"));
        }
    }
}

Results in an exception, even though this is clearly the correct Automation ID, the application crashes because it is unable to find that automation ID.

UEeTOHb.png

Any more suggestions? What can I do to change the value of this simple edit field? Is there any way that AutoIt can access it and change it?

Edited by azcn2503

Share this post


Link to post
Share on other sites
junkew

I am on W7 64 bits and no crashing of simplespy so you could try in a virtual machine how it behaves.

Make sure you run the simplespy in the 64bits version of AutoIT. Size of Long on 32bits is different then on 64bits

The "error" is in this area in the simplespy in the definition of the structure that for 64 bits most likely has to be different

could be that you only have to change these 2 lines

 Local $tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked.
 ;~ Local $tStruct = DllStructCreate("INT64,INT64")

Func GetElementInfo()
    Local $hWnd, $i, $parentCount
    Local $tStruct = DllStructCreate($tagPOINT) ; Create a structure that defines the point to be checked.
    ;~ Local $tStruct = DllStructCreate("INT64,INT64")
    ;~  ToolTip("")
    ;~ Global $UIA_oUIAutomation            ;The main library core CUI automation reference
    ;~ Global $UIA_oDesktop, $UIA_pDesktop       ;Desktop will be frequently the starting point

    ;~ Global $UIA_oUIElement, $UIA_pUIElement  ;Used frequently to get an element
    ;~ Global $UIA_oTW, $UIA_pTW         ;Generic treewalker which is allways available

    $x=MouseGetPos(0)
    $y=MouseGetPos(1)
    DllStructSetData($tStruct, "x", $x)
    DllStructSetData($tStruct, "y", $y)
;~  consolewrite(DllStructGetData($tStruct,"x") & DllStructGetData($tStruct,"y"))

;~ consolewrite("Mouse position is retrieved " & @crlf)

    $UIA_oUIAutomation.ElementFromPoint($tStruct,$UIA_pUIElement )

Share this post


Link to post
Share on other sites
LarsJ

azcn2503, You can try to run this code on the WinForms main window and the Windows 8 Enterprise node. The script lists all UI automation elements in the entire window. May be this script can recognize the Edit control. This script is very simple, and only depending on the constants and interface definitions in CUIAutomation2.au3, and nothing else.

 

#include "CUIAutomation2.au3"

Opt( "MustDeclareVars", 1 )

Global $oUIAutomation

MainFunc()


; List all automation elements of a window
; in a hierarchical structure like a treeview.
Func MainFunc()

  ; Get window handle
  ;Local $hWindow = 0x0006045C                                                             ; Infragistics
  ;Local $hWindow = WinGetHandle( "[CLASS:WindowsForms10.Window.8.app.0.bb8560_r19_ad1]" ) ; Infragistics
  ;Local $hWindow = WinGetHandle( "[REGEXPCLASS:WindowsForms10.Window.8.app.*]" )          ; Windows Updates Downloader
  ;Local $hWindow = WinGetHandle( "BCGPVisualStudioGUIDemo - Start Page" )                 ; BCGSoft BCGPVisualStudioGUIDemo
  ;Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]" )                                ; Windows Explorer, Windows 7
  ;Local $hWindow = WinGetHandle( "[CLASS:ExploreWClass]" )                                ; Windows Explorer, Windows XP
  ;Local $hWindow = WinGetHandle( "Windows Explorer right pane" )                          ; Windows Explorer right pane
  ;Local $hWindow = WinGetHandle( "[TITLE:My GUI Checkbox; CLASS:AutoIt v3 GUI]" )         ; AutoIt GUI window
  ;Local $hWindow = WinGetHandle( "[CLASS:AutoIt v3 GUI]" )                                ; AutoIt script
  ;Local $hWindow = WinGetHandle( "[CLASS:Chrome_WidgetWin_1]" )                           ; Chrome
  ;Local $hWindow = WinGetHandle( "[CLASS:IEFrame]" )                                      ; Internet Explorer
  Local $hWindow = WinGetHandle( "Calculator" )                                            ; Calculator
  If Not $hWindow Then Return ConsoleWrite( "Window handle error" & @CRLF )

  ; Create UI Automation object
  $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation )
  If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object error" & @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 error" & @CRLF )

  ; List all elements of window
  ListDescendants( $oWindow, 0, 0 )

EndFunc


; List all child elements of parent
Func ListDescendants( $oParent, $iLevel, $iLevels = 0 )

  If Not IsObj( $oParent ) Then Return
  If $iLevels And $iLevel = $iLevels Then Return

  ; Create RawViewWalker object
  Local $pRawViewWalker, $oRawViewWalker
  $oUIAutomation.RawViewWalker( $pRawViewWalker )
  $oRawViewWalker = ObjCreateInterface( $pRawViewWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker )
  If Not IsObj( $oRawViewWalker ) Then Return ConsoleWrite( "RawViewWalker object error" & @CRLF )

  ; Get first child element
  Local $pUIElement, $oUIElement
  $oRawViewWalker.GetFirstChildElement( $oParent, $pUIElement )
  $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )

  Local $sIndent = ""
  For $i = 0 To $iLevel - 1
    $sIndent &= "    "
  Next

  While IsObj( $oUIElement )
    ConsoleWrite( $sIndent & "Title     = " & _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _
                  $sIndent & "Class     = " & _UIA_getPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _
                  $sIndent & "Ctrl type = " & _UIA_getPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _
                  $sIndent & "Ctrl name = " & _UIA_getPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _
                  $sIndent & "Value     = " & _UIA_getPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _
                  $sIndent & "Handle    = " & Hex( _UIA_getPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF )

    ListDescendants( $oUIElement, $iLevel + 1, $iLevels )

    $oRawViewWalker.GetNextSiblingElement( $oUIElement, $pUIElement )
    $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
  WEnd

EndFunc


Func _UIA_getPropertyValue( $obj, $id )
  Local $tVal
  $obj.GetCurrentPropertyValue( $id, $tVal )
  If Not IsArray( $tVal ) Then Return $tVal
  Local $tStr = $tVal[0]
  For $i = 1 To UBound( $tVal ) - 1
    $tStr &= "; " & $tVal[$i]
  Next
  Return $tStr
EndFunc

Share this post


Link to post
Share on other sites
azcn2503

azcn2503, You can try to run this code on the WinForms main window and the Windows 8 Enterprise node. The script lists all UI automation elements in the entire window. May be this script can recognize the Edit control. This script is very simple, and only depending on the constants and interface definitions in CUIAutomation2.au3, and nothing else.

 

#include "CUIAutomation2.au3"

Opt( "MustDeclareVars", 1 )

Global $oUIAutomation

MainFunc()


; List all automation elements of a window
; in a hierarchical structure like a treeview.
Func MainFunc()

  ; Get window handle
  ;Local $hWindow = 0x0006045C                                                             ; Infragistics
  ;Local $hWindow = WinGetHandle( "[CLASS:WindowsForms10.Window.8.app.0.bb8560_r19_ad1]" ) ; Infragistics
  ;Local $hWindow = WinGetHandle( "[REGEXPCLASS:WindowsForms10.Window.8.app.*]" )          ; Windows Updates Downloader
  ;Local $hWindow = WinGetHandle( "BCGPVisualStudioGUIDemo - Start Page" )                 ; BCGSoft BCGPVisualStudioGUIDemo
  ;Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]" )                                ; Windows Explorer, Windows 7
  ;Local $hWindow = WinGetHandle( "[CLASS:ExploreWClass]" )                                ; Windows Explorer, Windows XP
  ;Local $hWindow = WinGetHandle( "Windows Explorer right pane" )                          ; Windows Explorer right pane
  ;Local $hWindow = WinGetHandle( "[TITLE:My GUI Checkbox; CLASS:AutoIt v3 GUI]" )         ; AutoIt GUI window
  ;Local $hWindow = WinGetHandle( "[CLASS:AutoIt v3 GUI]" )                                ; AutoIt script
  ;Local $hWindow = WinGetHandle( "[CLASS:Chrome_WidgetWin_1]" )                           ; Chrome
  ;Local $hWindow = WinGetHandle( "[CLASS:IEFrame]" )                                      ; Internet Explorer
  Local $hWindow = WinGetHandle( "Calculator" )                                            ; Calculator
  If Not $hWindow Then Return ConsoleWrite( "Window handle error" & @CRLF )

  ; Create UI Automation object
  $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation )
  If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "UI Automation object error" & @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 error" & @CRLF )

  ; List all elements of window
  ListDescendants( $oWindow, 0, 0 )

EndFunc


; List all child elements of parent
Func ListDescendants( $oParent, $iLevel, $iLevels = 0 )

  If Not IsObj( $oParent ) Then Return
  If $iLevels And $iLevel = $iLevels Then Return

  ; Create RawViewWalker object
  Local $pRawViewWalker, $oRawViewWalker
  $oUIAutomation.RawViewWalker( $pRawViewWalker )
  $oRawViewWalker = ObjCreateInterface( $pRawViewWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker )
  If Not IsObj( $oRawViewWalker ) Then Return ConsoleWrite( "RawViewWalker object error" & @CRLF )

  ; Get first child element
  Local $pUIElement, $oUIElement
  $oRawViewWalker.GetFirstChildElement( $oParent, $pUIElement )
  $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )

  Local $sIndent = ""
  For $i = 0 To $iLevel - 1
    $sIndent &= "    "
  Next

  While IsObj( $oUIElement )
    ConsoleWrite( $sIndent & "Title     = " & _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _
                  $sIndent & "Class     = " & _UIA_getPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _
                  $sIndent & "Ctrl type = " & _UIA_getPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _
                  $sIndent & "Ctrl name = " & _UIA_getPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _
                  $sIndent & "Value     = " & _UIA_getPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _
                  $sIndent & "Handle    = " & Hex( _UIA_getPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF )

    ListDescendants( $oUIElement, $iLevel + 1, $iLevels )

    $oRawViewWalker.GetNextSiblingElement( $oUIElement, $pUIElement )
    $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )
  WEnd

EndFunc


Func _UIA_getPropertyValue( $obj, $id )
  Local $tVal
  $obj.GetCurrentPropertyValue( $id, $tVal )
  If Not IsArray( $tVal ) Then Return $tVal
  Local $tStr = $tVal[0]
  For $i = 1 To UBound( $tVal ) - 1
    $tStr &= "; " & $tVal[$i]
  Next
  Return $tStr
EndFunc

 

Hi, I just tried this and it produced the following output:

Title     = 
Class     = 
Ctrl type = 50037
Ctrl name = title bar
Value     = Site Setup
Handle    = 00000000

    Title     = Minimize
    Class     = 
    Ctrl type = 50000
    Ctrl name = button
    Value     = 
    Handle    = 00000000

    Title     = Maximize
    Class     = 
    Ctrl type = 50000
    Ctrl name = button
    Value     = 
    Handle    = 00000000

    Title     = Close
    Class     = 
    Ctrl type = 50000
    Ctrl name = button
    Value     = 
    Handle    = 00000000

Share this post


Link to post
Share on other sites
LarsJ

This means that the container/pane/window control which contains the Edit control, is not properly recognized by the UI Automation framework.

You can try to use SimpleSpy.au3 to find a window at a lower level which contains the Edit control, and then run the script with this window. You can type in the window handle directly in the script.

Share this post


Link to post
Share on other sites
junkew

another one but that will give a huge log so close as many screens as possible and close all browsers

#include <GuiEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include "UIAWrappers.au3"

;enum TreeScope
;Global Const $TreeScope_Element=1
;Global Const $TreeScope_Children=2
;Global Const $TreeScope_Descendants=4
;Global Const $TreeScope_Parent=8
;Global Const $TreeScope_Ancestors=16
;Global Const $TreeScope_Subtree=7

_UIA_DumpThemAll($UIA_oDesktop,$TreeScope_Subtree)

Share this post


Link to post
Share on other sites
azcn2503

This means that the container/pane/window control which contains the Edit control, is not properly recognized by the UI Automation framework.

You can try to use SimpleSpy.au3 to find a window at a lower level which contains the Edit control, and then run the script with this window. You can type in the window handle directly in the script.

 

Just tried using this again in both x86 and x64 mode and it crashes every time I press Ctrl+W in the window I am trying to manipulate.

 

 

another one but that will give a huge log so close as many screens as possible and close all browsers

#include <GuiEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>
#include "UIAWrappers.au3"

;enum TreeScope
;Global Const $TreeScope_Element=1
;Global Const $TreeScope_Children=2
;Global Const $TreeScope_Descendants=4
;Global Const $TreeScope_Parent=8
;Global Const $TreeScope_Ancestors=16
;Global Const $TreeScope_Subtree=7

_UIA_DumpThemAll($UIA_oDesktop,$TreeScope_Subtree)

 

Thanks for this. I just tried running the code, but it does not produce any output or any error messages. It takes about 1.5s to run, but nothing appears in the console.

Share this post


Link to post
Share on other sites
LarsJ
junkew

A script that should type something in your box

#include "UIAWrappers.au3"
;~  Some settings to use as a default as set within the uiawrappers
;~  _UIA_setVar("Global.Debug", True)
;~  _UIA_setVar("Global.Debug.File", True)
;~  _UIA_setVar("Global.Highlight", True)
    
_UIA_setVar("MyWindowsForm.Mainwindow","Title:=Site Setup.*")
_UIA_setVar("MyEdit","Title:=Port.*;controltype:=UIA_EditControlTypeId;class:=WindowsForms10.EDIT.app.*"

_UIA_Action("MyWindowsForm.Mainwindow","setFocus")
_UIA_Action("MyEdit","setfocus")

_UIA_Action("MyEdit","setvalue","Try 1")
_UIA_Action("MyEdit","setvalue using keys","Try 2")
_UIA_Action("MyEdit","type","Try 3")
Exit

Share this post


Link to post
Share on other sites
azcn2503

 

A script that should type something in your box

#include "UIAWrappers.au3"
;~  Some settings to use as a default as set within the uiawrappers
;~  _UIA_setVar("Global.Debug", True)
;~  _UIA_setVar("Global.Debug.File", True)
;~  _UIA_setVar("Global.Highlight", True)
    
_UIA_setVar("MyWindowsForm.Mainwindow","Title:=Site Setup.*")
_UIA_setVar("MyEdit","Title:=Port.*;controltype:=UIA_EditControlTypeId;class:=WindowsForms10.EDIT.app.*"

_UIA_Action("MyWindowsForm.Mainwindow","setFocus")
_UIA_Action("MyEdit","setfocus")

_UIA_Action("MyEdit","setvalue","Try 1")
_UIA_Action("MyEdit","setvalue using keys","Try 2")
_UIA_Action("MyEdit","type","Try 3")
Exit

 

Hi, thanks for this. There seems to be some error in the script. Should I have customised it in some way? The error is as follows:

"D:\Downloads\EXAMPLES\test.au3" (8) : ==> Error parsing function call.:
_UIA_setVar("MyEdit","Title:=Port.*;controltype:=UIA_EditControlTypeId;class:=WindowsForms10.EDIT.app.*"
_UIA_setVar("MyEdit",^ ERROR
>Exit code: 1    Time: 0.3001

I also checked out the log file and indeed it is a very large file. Would you like me to paste the entire contents of that here?

Ctrl+W is not used in the application, the only keystrokes it can accept are Alt+S (Create &site) and Alt+C (&Cancel).

Edited by azcn2503

Share this post


Link to post
Share on other sites
junkew

Seems like I missed the closing parenthesis on that line with copy/pasting add the ) to that line.

Other questions that can be relevant

  • which version of AutoIT are you on?
  • Use the latest release which is not a beta
  • You can attach the logfile assuming it are not megabytes to your post (can allways be deleted later)

 

After the weekend I will post a new Work in Progress set to first post of IUIAutomation thread so main files are in sync but doubt if that influences what you observe.

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  

×