Using White / UIAutomation How to get the right-click context menu

When using UIAutomation, I seem to be unable to get a link to the context menu that appears when I execute a right-click command.

The following example shows the case when I opened a new window using (Windows Explorer inside it), got the correct link from the available DesktopWindows (note that I can move it in order) and called up the context menu via the right -Click.

var windowName = "This is a WinForms window: {0}".format(3.randomLetters()); var topPanel = O2Gui.open<Panel>(windowName,600,200 ); var webBrowser = topPanel.add_WebBrowser_Control(); webBrowser.open("".o2Temp2Dir()); var guiAutomation = new API_GuiAutomation(); var window = guiAutomation.desktopWindow(windowName); window.move(0,0); window.mouse_MoveTo(); guiAutomation.mouse().rightClick(); window.infoTypeName(); return window.Popup; //O2File:API_GuiAutomation.cs //O2Ref:White.Core.dll //O2Ref:UIAutomationClient.dll 

I tried using the window.Popup variable to get the popup, but it was null (not that the window object is of type White.Core.UIItems.WindowItems.WinFormWindow

+4
source share
2 answers

It looks like you answered your question: http://white.codeplex.com/discussions/250129
;)

EDIT: I found a way to do this:

 public static PopUpMenu getContextMenu(this API_GuiAutomation guiAutomation) { try { var emptyWindow = guiAutomation.desktopWindow(""); return emptyWindow.Popup; } catch { } return null; } 

which can then be used as follows:

  var contextMenu = guiAutomation.getContextMenu(); contextMenu.menu("Git Clone...").click(); 
+1
source
 static PopUpMenu GetCurrentPopUpMenu(){ List<Window> windows = WindowFactory.Desktop.DesktopWindows(); foreach(Window w in windows) { if(w.Name == "") return w.PopUp; } return null; } 
+1
source

Source: https://habr.com/ru/post/1344138/


All Articles