4

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変数を使用してポップアップを取得しようとしましたが、それはnullでした(ウィンドウオブジェクトのタイプがWhite.Core.UIItems.WindowItems.WinFormWindowであるというわけではありません)。

4

2 に答える 2

1

ここであなた自身の質問に答えたようです:http
://white.codeplex.com/discussions/250129 ;)

編集:私はこれを行う方法を見つけました:

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

これは次のように消費できます:

    var contextMenu =  guiAutomation.getContextMenu();
    contextMenu.menu("Git Clone...").click();
于 2011-05-05T01:57:45.127 に答える
1
static PopUpMenu GetCurrentPopUpMenu(){

    List<Window> windows = WindowFactory.Desktop.DesktopWindows();
    foreach(Window w in windows)
    {
        if(w.Name == "") return w.PopUp;
    }
    return null;
}
于 2012-05-24T08:57:52.337 に答える