I am trying to use the MS UI Automation Framework in my application for some automated testing. My goal at this time is to listen for GUI events and record them, similar to the provided sample (TestScriptGeneratorSample) in the Windows SDK.
Just using this demo application, I can start a simple Windows Forms application with a single button and see that it logs click events as a βtriggerβ UIA event. However, for each press of a button, the demo application logs events 4 . Why is this? I do not see this problem when using the WPF button.
I assume that since the System.Windows.Forms.Button class supports MSAA instead of MCA, the part of the MCA that connects the MSAA interface is to behave badly or at least to behave in a way that I do not understand and cannot find the documentation. Maybe it reports an invoke event for the mouse to click down, up, click, and then press the actual button?
Can someone explain this behavior and / or provide a workaround so that a single click of a button leads to a single call event?
Edit: This is under WinXP SP3. I just installed the Windows Automation API 3.0 update and still see the same behavior.
Edit 2: I found this example where the author offline mentions this behavior as an error in Win32, but does not provide any evidence ...
Here is my sample application (a form with a button on it), as well as listening to events. Add links to UIAutomationClient and UIAutomationTypes . Press the button and see how invoke are executed four times instead of one.
using System; using System.Drawing; using System.Windows.Automation; using System.Windows.Forms; namespace WindowsFormsApplication6 { public partial class Form1 : Form { private TextBox m_Output; public Form1() { InitializeComponent();
source share