JamesH Posted August 19, 2008 Posted August 19, 2008 (edited) I'm using AutoItX to handle a java applet that pops up during some web automation that I'm doing. It works fine on my development system, but if anybody else tries to run it it fails. I tracked down the problem to a WinExists call. When the WinExists is called, the java applet closes and the next Send causes an AccessViolationException. I'm working around it by running an external AutoIt script, but that has problems of its own. With this going through .NET and COM, and interacting with Java, there's a lot of possible points of failure here. Before I drive myself mad trying to track this down, I just wanted to see if anybody would have insight into what is going wrong. Remember this works on my development system, but nowhere else. Also the external program that does the exact same thing works (mostly) fine. C#: AutoItX3Class automator = new AutoItX3Class(); Stopwatch timer = new Stopwatch(); bool done = false; bool timeout = false; System.Threading.Thread.Sleep(10000); //Applet sometimes doesn't appear without a wait, possibly related to WinExists problem? timer.Start(); while (!done && !timeout) //Usually only executed once because the window appears by the time the earlier Sleep is done { if (automator.WinExists("Select a directory to save", "") == 1) //<-Window closes here { automator.WinActivate("Select a directory to save", ""); automator.Send("+{END}", 0); //<-AccessViolationException occurs here automator.Send(Util.duFilePath + "{ENTER}", 0); //Util.duFilePath is just a string constant with a directory name System.Threading.Thread.Sleep(1000); automator.ControlClick("Select a directory to save", "", "SunAwtCanvas9", "left", 1, 10, 10); //Click the save button done = true; } else if (automator.WinExists("Warning - Security", "") == 1) { automator.WinActivate("Warning - Security", ""); automator.Send("{ENTER}", 0); } if (!done) timeout = (timer.ElapsedMilliseconds > 120000); } timer.Stop(); if (timeout) throw new Exception("Timed out while using export download utility."); automator.WinWaitClose("Download Progress", "", 120); Edited August 19, 2008 by JamesH
amokoura Posted August 19, 2008 Posted August 19, 2008 Good luck with that one The problem seems so deep that I might try some direct WinAPI or .NET's own window inspectors (If there were any..) At least then you wouldn't need an external script
Richard Robertson Posted August 20, 2008 Posted August 20, 2008 I don't believe .Net has anything built in for checking windows, but you can call EnumWindows pretty easily and check for the window yourself.
amokoura Posted August 20, 2008 Posted August 20, 2008 Once I accidentally found some automation/accessibility classes that seemed to have some window checking abilities. The namespace was huge so I returned to the good old AutoItX. It was a quick look into .net docs. I might be wrong.
JamesH Posted August 20, 2008 Author Posted August 20, 2008 Not the answer I wanted, but it was the one I needed. Looks like I'll have to spend time with good ol' pinvoke.net. Thanks.
amokoura Posted August 21, 2008 Posted August 21, 2008 This dude had also some AutoItX WinExist problems: http://www.autoitscript.com/forum/index.ph...c=78395&hl=
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now