简体   繁体   English

自动化事件不起作用? C#自动化UI

[英]Automation Event not working ? C# AUTOMATION UI

I am using AUTOMATION UI and added all refrences like UIAUOMATION CLIETNT AND TYPE but my function 我正在使用AUTOMATION UI,并添加了所有引用,例如UIAUOMATION CLIETNT和TYPE,但是我的功能

       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();

stops working for some dialogues like open , save , prefrences but working for others in dialogue i am registering events so it is compulsory that my events also fires for dialogue boxes point to be noted 停止进行某些对话(例如打开,保存,首选项),但是在对话中为其他对话工作,我正在注册事件,因此必须注意我的事件也会触发,对话框必须指出

System.Console.Read(); System.Console.Read();

Automation.RemoveAllEventHandlers(); Automation.RemoveAllEventHandlers();

1-Above code system.console.ReadKey(); 1-以上代码system.console.ReadKey(); also gives error as it is in webservice have no console mode 也出现错误,因为它在webservice中没有控制台模式

2-open and save dialogue are not detected 未检测到2次打开和保存对话框

3-and also it is very slow 3,而且也很慢

similar to that question 类似于那个问题

link to similar problem 链接到类似问题

Try inspecting the open/save dialogues to make sure their localizedControlType is what you expect. 尝试检查打开/保存对话框,以确保其localizedControlType符合您的期望。

You can use uispy to do this. 您可以使用uispy执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM