我可以打开它,但我无法点击。
我试试
public RecordProgram()
{
ProcessStartInfo psi = new ProcessStartInfo(@"C:\MouseController.exe", @"C:\test1.mcd");
psi.UseShellExecute = false;
_calculatorProcess = Process.Start(psi);
int ct = 0;
do
{
_calculatorAutomationElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "MouseController (1,0x)"));
++ct;
Thread.Sleep(100);
}
while (_calculatorAutomationElement == null && ct < 50);
if (_calculatorAutomationElement == null)
{
throw new InvalidOperationException("Calculator must be running");
}
//This line returns null
_resultTextBoxAutomationElement = _calculatorAutomationElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "920388"));
if (_resultTextBoxAutomationElement == null)
{
//Ever get null
throw new InvalidOperationException("Could not find result box");
}
GetInvokePattern(GetFunctionButton(Functions.StartPlayBack)).Invoke();
}
程序运行并使用我的文件加载打开可执行文件但是_resultTextBoxAutomationElement返回空值。