How can I programmatically click a Button?

Button, like many other WPF controls, has a peer class in the
System.Windows.Automation.Peers namespace to support UI Automation:
ButtonAutomationPeer. It can be used as follows with a Button called myButton:
ButtonAutomationPeer bap = new ButtonAutomationPeer(myButton); 
IInvokeProvider iip = bap.GetPattern(PatternInterface.Invoke)
as IInvokeProvider; 
iip.Invoke(); // This clicks the Button
These UI Automation classes have several members that are extremely useful for automated
testing and accessibility.

댓글

이 블로그의 인기 게시물

Oracle NLS_DATE_FORMAT 변경

Stop console process using Ctrl+C.

Alternative to IValueConvert, QuickConverter