使用 White/UIAutomation 如何获取右键单击上下文菜单
使用 UIAutomation 时,我似乎无法获取对执行右键单击命令时显示的上下文菜单的引用。
下面的示例显示了我打开一个新窗口(其中包含 Windows 资源管理器)的情况,从可用的 DesktopWindows 中获取了其正确的引用(请注意,我可以移动它)并通过右键单击触发上下文菜单。
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
我尝试使用 window.Popup 变量来获取弹出窗口,但该变量为空(并不是窗口对象的类型为 White.Core.UIItems.WindowItems.WinFormWindow
When using UIAutomation I can't seem to be able to get a reference to the context menu that is shown when a right click is command is executed.
The following example shows a case where I opened up a new window with a (windows explorer inside it),got its correct reference from the available DesktopWindows (note that I can move it ok) and triggered the context menu via a 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 to use the window.Popup variable to get the popup but that was null (not that the window object is of type White.Core.UIItems.WindowItems.WinFormWindow
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您在这里回答了自己的问题:http://white.codeplex.com/discussions/250129
;)
编辑:我找到了一种方法来做到这一点:
然后可以像这样使用:
Looks like you answered your own question here: http://white.codeplex.com/discussions/250129
;)
EDIT: I found a way to do this:
which can then be consumed like this: