c# - Identifier for a Windows GUI element (AutomationElement HashCode and RuntimeID) -


i looking way identify instances of gui element (for example "copy" entry in context menu of windows explorer).

i tried both .gethashcode , .getruntimeid method on automationelement, both change each time open context menu.

what difference/purpose between runtimeid , hashcode anyway?

any ideas how identfy gui element without comparing label/name string?

there various ways, under automationelement class able inspect "current" element , use combination of ways determine element. following example taken 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 able access element.current , extract things such name, processid.

although may have figured out, following code should class name of current ui item, not part of automationelement class , 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 helps, if started ;)

rh


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -