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

  • Home
  • SEARCH
  • 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 4033128
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:48:31+00:00 2026-05-20T11:48:31+00:00

I am looking for a way to identify instances of a certain GUI element

  • 0

I am looking for a way to identify instances of a certain GUI element (for example the “copy” entry in the context menu of the Windows Explorer).

I tried both the .GetHashCode and the .GetRuntimeId method on the AutomationElement, but they both change each time I open the context menu.

What is the difference/purpose between RuntimeId and HashCode anyway?

Any ideas how I could identfy the GUI element without comparing the label/name string?

  • 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-05-20T11:48:31+00:00Added an answer on May 20, 2026 at 11:48 am

    There are various ways, however under the AutomationElement class you are able to inspect the “Current” element and use a combination of ways to determine the element. The following example was taken from another solution See Here

    using System.Window.Automation;        
    private AutomationElement element;
    System.Drawing.Point mouse = System.Windows.Forms.Cursor.Position;
    this.element = AutomationElement.FromPoint(new System.Windows.Point(mouse.X, mouse.Y));
    

    From here you are able to access the element.Current and extract things such as the Name, ProcessId.

    Although this may be something you have already figured out, the following code should help you get the class name of the current UI item, however its NOT a part of the AutomationElement class and is a Win32 hook.

    [DllImport("User32.dll")]
        public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
    
    private string GetClassName(IntPtr hWnd)
        {
            StringBuilder sb = new StringBuilder(256);
            this.GetClassName(hWnd, sb, 256);
            return sb.ToString();
        }
    

    Hope it helps, if only to get you started 😉

    RH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to uniquely identify instances of UITableViewCells even after they
I am looking for a way to identify quoted text in emails. The goal
I am looking for a way to identify (i.e. encode and decode) a set
I'm looking for a way to identify data, such that I prevent it from
I am looking for a way to uniquely identify an email at the time
A while ago I was looking for a way to uniquely identify a device
I am looking for a way to identify if user refreshes a page or
I'm looking for a way to identify the default permissions granted to a user
I'm looking for a way to identify a particular SQL Server Instance from a
I am looking for a way to identify primitives types in a template class

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.