How to get handle of context menu that is currently open without knowing the control that opened it? (test automation)

It is an infragistics popup shown from the ultraToolbarsManager. I am using UIAutomation which is not working. typically I use this to locate the an ms context menu

 AutomationElement menu = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Menu)); 

Luckily I am also injected into the app that is being tested but for the life of me I can’t figure out how to get the handle context menu that is currently open. TopLevelControl returns the form. I tried to pinvoke GetForegroundWindow but that just returned the same form and not the menu.

submitted by /u/dont_judge_me_monkey
[link] [comments]

Leave a Reply