开发者

AutoIT WinWaitActive issue

开发者 https://www.devze.com 2022-12-30 17:25 出处:网络
I have a C# application with windows forms, using which I need to automate the opening of a file using an in-house software( mySoftware). I have the following code as below. My understanding is that W

I have a C# application with windows forms, using which I need to automate the opening of a file using an in-house software( mySoftware). I have the following code as below. My understanding is that WinWaitActive() should wait until I click on the in-house software window (mySoftwareWindow) and make it active, before the code moves on to the next line and opens the specified xml file (line 6 in code below). Instead whats happening is that the next line of code runs even before I can make the in-house software active, thus running the Open button (line 6 in code below) on the current active window, which in this case is the C# application form. What do you think is going wrong here? Thanks!

 aut = new AutoItX3Lib.AutoItX3Class();
 aut.WinWaitActive("mySoftwareWindow", "", 1);
 aut.WinMenuSe开发者_如何学GolectItem("mySoftwareWindow", "", "&File", "&Open", "", "", "", "", "", "");
 aut.Send("C:\\test.xml", 0);
 //click the Open button
 aut.Send("!o", 0);
 aut.Send("{ENTER}", 0); 


The timeout is very short, 1 second isn't enough. Make time-outs at least 10 times the worst case, go for at least 20 here. And be sure to check the function return value, there's no point to continue if it returned failure.

0

精彩评论

暂无评论...
验证码 换一张
取 消