Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9022915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:38:01+00:00 2026-06-16T05:38:01+00:00

Using Microsoft UI Automation. I have a string which represents UIA control type, like

  • 0

Using Microsoft UI Automation. I have a string which represents UIA control type, like “Window” or “Button”. I would like to get a ControlType object which fits this string. How to do it? Is some enumerations exists which represents all the UIA control types? I found only that ControlType has ControlType.LookupById(int) method. But I have to know correspondence between ID and name. Of course, I can create my own switch with all the possible UIA control types, or even use reflection to get all the members of ControlType factory. But I’m sure should be easier way..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:38:03+00:00Added an answer on June 16, 2026 at 5:38 am

    I’ve found such way, using PresentationCore.dll, very strange for me, that such enum doesn’t exist in standart UIA DLL. Also please pay attention, that there is a bug in ControlType class, I guess due to its private static constructor. If you call ControlType.LookupById(enumId) 1st time, it will return null, but in the 2nd time will be OK. The solution is quite simple — just call ToString before usage, it will initialize the static constructor 🙂

        using System.Windows.Automation.Peers;
    
        // solving the bug with static constructor of ControlType..
        ControlType.Button.ToString();
        string controlTypeString = "Window";
        AutomationControlType typeEnum;
        bool result = Enum.TryParse(controlTypeString, true, out typeEnum);
        if (result) typeEnum = (AutomationControlType)Enum.Parse(typeof(AutomationControlType), controlTypeString);
        int enumId = (int)typeEnum + 50000;
        ControlType controlType = ControlType.LookupById(enumId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel 2010 Automation project using Microsoft Office Interop library in C#.NET.
I have a small application which automates Microsoft Word via COM/OLE Automation. Unfortunately this
When using Microsoft office automation I want to insert images into a spreadsheet. How
Using Microsoft Visual Studio 2010: Can I write this type of macro in C?
Using Microsoft SQL server 2008 I have a query that is in need of
I recently implemented a program using the Microsoft Accessibility API, but have since been
I'm using C# office ( word ) automation by Microsoft Office 12.0 Object Library
am trying to use automation in from Microsoft Access 2003 to control Internet Explorer
I have created an ActiveX control using C++. I use Visual Basic code to
Using Microsoft SQL Server 2005, is there any way to see when a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.