2016-07-25 47 views
0

我使用的自動化UI,並添加像UIAUOMATION CLIETNT和所有refrences類型,但我的功能自動化事件不起作用? C#自動化UI

 Automation.AddAutomationEventHandler(
      WindowPattern.WindowOpenedEvent, 
      AutomationElement.RootElement, 
        System.Windows.Automation.TreeScope.Subtree, 
          (sender, e) => 
          { 
           var element = sender as AutomationElement; 
          if (element.Current.LocalizedControlType == "Dialog") 
           { 

           } 
          }); 

    System.Console.ReadKey(); 
    Automation.RemoveAllEventHandlers(); 

停止像開了一些對話,請保存,prefrences但對於其他人對話的工作我是註冊事件所以我的事件也是強制性的,因爲對話框需要注意的點

System.Console.Read();

Automation.RemoveAllEventHandlers();

1-以上代碼system.console.ReadKey();也給出了錯誤,因爲它是在web服務沒有控制檯模式

2,打開和保存對話都沒有檢測

3,並且也很慢

類似問題

link to similar problem

+0

NO AUTOMATION GURU –

回答

-1

嘗試檢查打開/保存對話框以確保它們的localizedControlType是您所期望的。

您可以使用uispy來做到這一點。