Jump to content

Recommended Posts

Posted (edited)

I have a project in mind that I would like to share.
I would like to create example windows with standard elements like ComboBox, ListView, some Button, some text, some edit field.

Nothing special just simple Window.Net form that can be created with this following UDF:

or this one:

 

The main idea is to easily provide possible modifications to the "Testing GUI Window", and no need for any other tool than the AutoIt + SciTE kit.

Such "Testing GUI Window" will be very useful later on topic/threads/projects like:


As I am not very familiar with NetFramework, I would like to ask for help with this project.

Thanks in advance for any help.
@mLipok

 

 

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • mLipok changed the title to NetFramework example GUI to use them with UIAutomation
Posted
  • What do you mean with "Testing GUI Window"? 
    • Are you referring to au3inf?
  • The main idea is to easily provide possible modifications to the "Testing GUI Window", and no need for any other tool than the AutoIt + SciTE kit.
    • But how do you see this new tool then?
  • Not sure what you miss in the current tool set exactly?
    • simplespy and uiaspy deliver code snippets for all elements that are uia compatible
  • "I would like to create example windows with standard elements like ComboBox, ListView, some Button, some text, some edit field."
    • So this means: In each example window one specific element? 
    • What would you do then with such kind of example window.
Posted (edited)

You should get free version of Visual Studio and make an example form with all the controls you want to interact with. With a C# project it should be pretty easy to drag and drop, then build. then you can use those udfs on it. 

 

Visual Studio 2022 Community Edition – Download Latest Free Version (microsoft.com)

 

all you need is the .NET development Desktop to do this, they may have samples you can just build and run based on Winforms or new xml forms, oh whats their name, getting old

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

make yourself a small vm, 2gb ram and 2 cores and install this and use it to develop and learn, don't install it on a host. my sage advice with visual studio

My resources are limited. You must ask the right questions

 

Posted

By default, no UIA code in C# or VB.NET applications
Note that an example GUI created as described in first post will generally not contain UIA code to automate the controls. Only standard Windows controls that can already be automated with classic code will also be able to automate with UIA code. Other controls including all the interesting .NET controls, e.g. the DataGridView control, which is not derived from the standard controls, can only be automated with MSAA code. By default, a program created with C# or VB.NET code will not contain UIA code except for the standard Windows controls. Otherwise only MSAA code.

At top of this post is an example with the DataGridView control, which clearly demonstrates this. tst00.vb and tst00.au3 can be found in GridControls.7z at bottom of said post. Running tst00.au3 creates a GUI like this:

9CgVOOJ.png

UIASpy shows the element tree structure for all controls throughout the GUI as follows: 

0000    Window: WindowsForms10.Window.8.app.0.3e799b_r35_ad1
0001        Pane: WindowsForms10.Window.8.app.0.3e799b_r35_ad1
0002            Button: Add Row
0003            Button: Delete Row
0004        Table: DataGridView
0005            Custom: Top Row
0006                Header: Title
0007                Header: Artist
0008                Header: Album
0009                Header: Release Date
0010                Header: Track
0011            Custom: Row 0
0012                Custom: Title Row 0
0013                Custom: Artist Row 0
0014                Custom: Album Row 0
0015                Custom: Release Date Row 0
0016                Custom: Track Row 0
0017            Custom: Row 1
0018                Custom: Title Row 1
0019                Custom: Artist Row 1
0020                Custom: Album Row 1
0021                Custom: Release Date Row 1
0022                Custom: Track Row 1
0023            Custom: Row 2
0024                Custom: Title Row 2
0025                Custom: Artist Row 2
0026                Custom: Album Row 2
0027                Custom: Release Date Row 2
0028                Custom: Track Row 2
0029            Custom: Row 3
0030                Custom: Title Row 3
0031                Custom: Artist Row 3
0032                Custom: Album Row 3
0033                Custom: Release Date Row 3
0034                Custom: Track Row 3
0035            Custom: Row 4
0036                Custom: Title Row 4
0037                Custom: Artist Row 4
0038                Custom: Album Row 4
0039                Custom: Release Date Row 4
0040                Custom: Track Row 4
0041            Custom: Row 5
0042                Custom: Title Row 5
0043                Custom: Artist Row 5
0044                Custom: Album Row 5
0045                Custom: Release Date Row 5
0046                Custom: Track Row 5
0047            Custom: Row 6
0048                Custom: Title Row 6
0049                Custom: Artist Row 6
0050                Custom: Album Row 6
0051                Custom: Release Date Row 6
0052                Custom: Track Row 6
0053            Custom: Row 7
0054                Custom: Title Row 7
0055                Custom: Artist Row 7
0056                Custom: Album Row 7
0057                Custom: Release Date Row 7
0058                Custom: Track Row 7
0059        TitleBar
0060            MenuBar: System
0061                MenuItem: System
0062            Button: Minimize
0063            Button: Maximize
0064            Button: Close

Recognized controls can be automated with UIA code. Custom controls can only be automated with MSAA code.

The $UIA_ProviderDescriptionPropertyId, which is a text string, provides some information about how a window or control can be automated: 

[pid:4496,hwnd:0x602D2 Main:Nested [pid:2976,hwnd:0x602D2 Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]

If the string contains Proxy substrings such as Microsoft: MSAA Proxy or Microsoft: HWND Proxy, it can be automated with MSAA code or classic code. There are many different of these Proxy substrings.

To add more UIA code to the program take a look at the UI Automation Provider Programmer's Guide. It's not necessarily completely trivial.

I don't know if it's possible through Visual Studio to more easily add at least default UIA code to actual .NET controls implemented in C# or VB.NET. Maybe junkew or Earthshine know something about this.

At first glance, I think it's easier to test with existing programs that already contain more complete UIA code e.g. File Explorer and Calculator. Whether testing with File Explorer and Calculator or with .NET programs is completely indifferent to the UIA code. The UIA code to click a button, a menu item, set a selection in a table, or expand/collapse a treeview control element as well as other automation actions is exactly the same for all programs, as long as the controls support the required UIA code. 

In UIA code, automation actions as mentioned above are implemented through pattern interfaces.

There are already a number of examples of the use of these automation actions and similar pattern interfaces in this post. Then it might be the easiest place to start. If you want, you can test some of the examples in other programs.

Posted (edited)

@Larsjm you are correct in that C# WPF apps do not automatically provide for client utilization of UIAutomation. The app developer can add that in.

 

UI Automation Overview - .NET Framework | Microsoft Docs

UI Automation of a Custom Control - WPF .NET Framework | Microsoft Docs

Server-Side UI Automation Provider Implementation - .NET Framework | Microsoft Docs

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted
  • Still adding it in by your developers is a lot of googling around in bits and pieces on how for example automationid can be set for WPF
<ListView IsEnabled="{Binding TestSelectorEnabled}" x:Name="ListView1"  ItemsSource="{Binding TestsDataTable}" SelectedValue="{Binding SelectedTest}" SelectedValuePath="TestName" Height="180" View="{Binding GridView}"  TabIndex="0" MinWidth="1" Focusable="False">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="AutomationProperties.AutomationId" Value="{Binding Path=DataContext.TestsViewModel.ListItemCounter, StringFormat='dataitem{0:F0}', UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}}"/>
                </Style>
            </ListView.ItemContainerStyle>
</ListView>

https://cmakara.github.io/posts/how-to-set-automationid-for-treeviewitems-in-wpf

 

  • Even for HTML 5 I have never found an easy reference for UIA and what developers should add to their HTML to get automationid in UIA nicely filled  (id seems best but then automationid jumps sometimes from textbox element to a div element and still have then to search the next innerchild with a treewalker.
    https://www.w3.org/TR/core-aam-1.2/#mapping_state-property_table is the best part I found for HTML.
    Would be nice if it could be handled more with UIA so then no mix of webdriver and UIA stuff in framework.

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
×
×
  • Create New...