一 、form
button.PerformClick();
二、wpf
wpf中没有提供这个方法 google一番 可以使用自动化测试工具封装好的dll来实现
UIAutomationProvider.dll
下载地址:http://originaldll.com/file/uiautomationprovider.dll/8066.html
使用方法
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
/// <summary>
/// 扩展方法 该类必须设置成static
///