Jump to content

Recommended Posts

Posted

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?

Posted (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 by stoli
Posted (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 by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...