Microsoft UI Automation: ValuePattern not supported for RICHEDIT60W

余生颓废 提交于 2020-01-04 14:29:51

问题


I'm developing an UI Automation application for Microsoft Word and I need to catch, for a RichEdit text box, the "AutoAddAutomationPropertyChanged" Event via a specific handler through method "AddAutomationPropertyChangedEventHandler". I have my AutomationElement "element" that represents the RichEdit control and I added the event on my class:

Automation.AddAutomationPropertyChangedEventHandler(element, TreeScope.Subtree, OnPropertyChanged, new[] { ValuePattern.ValueProperty });

and my handler is:

 private void OnPropertyChanged(object sender, AutomationPropertyChangedEventArgs e)
    {
        if (e.Property == ValuePattern.ValueProperty)
        {
            ...code...
        }
    }

The problem is that if I execute this code on a RichEdit of type "RichEdit20W" it works and it catches the event, entering into OnPropertyChanged handler method. My problem is execute this code on a RICHED60W text control: it seems that the event is never triggered from Richedit60w text control so I cannot catch it to execute my handler code.

For example, with Microsoft Word 2010, if I execute this code using the RichEdit control of the window "Find&Replace", it works and the handler code is executed. Contrarily, if I execute the code using the RichEdit text control on the left of main Word application window, which is a RICHEDIT60W ("Navigation" pane, opened with CTRL + F, and I used Inspect.exe tool to check it), it does not work and the handler code is never executed. I'm very confused because if I try to catch the same property value changed event on RICHEDIT60W with Accevent.exe tool supplied by Windows SDK, the tool works properly and displays the event information.

I tried everything, even with TreeScope.Element and TreeScope.Children parameters on method, but nothing happens.

I follow this: http://msdn.microsoft.com/en-us/library/system.windows.automation.valuepattern.valueproperty(v=vs.110).aspx

to check if the element supports value pattern (obviously it supports...), and this:

set text on textfield / textbox with the automation framework and get the change event

Thanks in advance and sorry for my English.

来源:https://stackoverflow.com/questions/22410643/microsoft-ui-automation-valuepattern-not-supported-for-richedit60w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!