stoli Posted November 9, 2007 Share Posted November 9, 2007 I have been using AutoItX3 in a Java app for a few days now and have been fairly successful at getting it to do what I want. This morning, Java started throwing an Exception when calling the AutoItSetOption method. It had worked fine for a few days, which is really puzzling me. I am using it to close down all instances of a certain IE browser window that might happen to be running at the time of execution. Here is the code: ... appAutoIt = new IAutoItX3("AutoItX3.Control"); appAutoIt.init(); appAutoIt.AutoItSetOption("WinTitleMatchMode", 2); <------- Error occurs here while (appAutoIt.WinExists("MyMatchString", "") == 1) { appAutoIt.WinKill("MyMatchString", ""); } I know this is rather vague and the error is cryptic since it is coming from a wrapper (jawin), but I was curious if anyone might have some insight. Don't want to offer up any red herrings, but after plowing through the error messages, it could be a permission issue. Any ideas? Link to comment Share on other sites More sharing options...
stoli Posted November 10, 2007 Author Share Posted November 10, 2007 (edited) Got it working again. Not sure about the AutoItSetOption deal. I'm debugging using JBuilder and was doing some tests from a .jsp page, so that could be contributing. The one thing I did find was that the string parameter in the WinExists method can not be null. So "" doesn't work but a space " " works fine . WinExists("MyMatchString", "") <-----Bad WinExists("MyMatchString", " ") <-----Good Same for the WinKill method. Regards Edited November 10, 2007 by stoli Link to comment Share on other sites More sharing options...
Blue_Drache Posted November 10, 2007 Share Posted November 10, 2007 (edited) About your original question: In my VBA code, I've not had any trouble out of setting the Opts... With oAI .Opt "MouseCoordMode", 0 .Opt "WinTitleMatchMode", 2 .WinActivate "C - [24 x 80]" .Sleep 500 .MouseClick "primary", 680, 78, 1, 1 If .WinWait("Is Provider Name Correct?", "&Cancel", 30) = 0 Then MsgBox "Possible clocking situation on C emulator", vbOKOnly, "Error" Exit Function End If .WinActivate "Is Provider Name Correct?", "&Cancel" As you can see, I don't surround the code with Parenthesis, unless I'm setting the return value to a variable or other conditional test. Could that have been the problem? Also, the text portion is optional. Don't even bother putting a "" or " " in there. Edited November 10, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 10, 2007 Share Posted November 10, 2007 To the best of my knowledge, java doesn't support optional parameters. Link to comment Share on other sites More sharing options...
stoli Posted November 12, 2007 Author Share Posted November 12, 2007 Thanks for the feedback. The parentheses are a syntax thing with java. And, yes, java doesn't support optional params so I need to send it something. Sending it a "space" instead of null seemed to make it happy. It's working pretty good now. Link to comment Share on other sites More sharing options...
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