Jump to content
Sign in to follow this  

AutoItX and Java

Recommended Posts

Can anybody tell me how to use AutoItX with Java.

I started to import Jacob into the class

import com.jacob.activeX.*;

import com.jacob.com.*;

and then getting the ActiveXComponent

ActiveXComponent AutoIt3 = new ActiveXComponent("AutoItX3.Control");

Everything ist fine. But what do I have do do now?

I just want to do some mouse & keyboard clicks. Nothing special

Edited by bjo

Share this post

Link to post
Share on other sites

First off, I'm surprised that java has any way to support ActiveX.

Second, click is spelled with a c in front.

Third, have you tryed standard dll calls?

public class AutoItFunctions
static AutoItFunctions()

public static native long AU3_MouseClick(String szButton, long nX, long nY, long nClicks, long nSpeed);}

I think native is used in that way but I haven't used java in a while.

Share this post

Link to post
Share on other sites


I'm trying to use AutoIt3.dll in a Java Application. I read all posts about Java on this forum but I didn't find any solution.

Here is my configuration :

- Java 1.6 (also tested with 1.5)

- Win XP

- AutoIt3.dll

And here is the code :

public class TestAutoIt {
    static { 

    // First Test :
    public static native long AU3_PixelGetColor(long nX, long nY);
    // Second Test;
    public static native int AU3_Run(String szRun, String szDir, long nShowFlags);

    public TestAutoIt () {
       // First test :
       // Second test :
       AU3_Run("notepad.exe", "", 1);


    public static void main(String[] args) {
        TestAutoIt testAutoIt = new TestAutoIt();

The library is loaded : there is no problem.

The problem concerns both tests :

First test :

Exception in thread "main" java.lang.UnsatisfiedLinkError: TestAutoIt.AU3_PixelGetColor(JJ)J
        at TestAutoIt.PixelGetColor(Native Method)
        at TestAutoIt.<init>(Main.java:42)
        at TestAutoIt.main(Main.java:73)
Java Result: 1

Second test :

Exception in thread "main" java.lang.UnsatisfiedLinkError: TestAutoIt.AU3_Run(Ljava/lang/String;Ljava/lang/String;J)J
        at TestAutoIt.AU3_Run(Native Method)
        at TestAutoIt.<init>(TestAutoIt .java:41)
        at TestAutoIt.main(TestAutoIt .java:73)
Java Result: 1

Somebody would see any problem in my source ? I wonder whether the problem doesn't come from the type long...

Thanks a lot in advance,

Best regards.

Share this post

Link to post
Share on other sites

You need to System.loadLibrary("autoitx.dll") using the literal name of the dll. You do not use the COM name of it.

The "unsatisfied link error" means that the Java runtime could not find the function when it was called. You can compile it because it didn't have any syntax errors. The errors occur at runtime for lack of a library.

Share this post

Link to post
Share on other sites

I already tried to use the literal name but when I use System.loadLibrary("AutoItX3.dll"), I have this error meaning that the library is not found :

java.lang.UnsatisfiedLinkError: no AutoItX3.dll in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at TestAutoIt.<clinit>(Main.java:29)
Exception in thread "main"

When I need to load some library "lib.dll", I usually write System.load("lib")...

Thanks for your support.

Share this post

Link to post
Share on other sites

Finally, I'm going to use the COM interface, it works fine with JACOB.

Here is some example :

// JACOB :
import com.jacob.com.*;
import com.jacob.activeX.*;

// Register the COM interface (/s means silent mode : it won't open msgbox...)
   Runtime.getRuntime().exec("regsvr32.exe /s AutoItX3.dll");
} catch (IOException ex){

// Open notepad.exe
ActiveXComponent AutoIt3 = new ActiveXComponent("AutoItX3.Control");

with AutoItX3.dll and jacob.dll in the java.library.path, and jacob.jar in the classpath.

Naturally, I'm interested in a better solution.

Best regards.

Share this post

Link to post
Share on other sites

hey kewixi...

i am using eclipse and i tried to run your example, in vm arguments in the run properties i




and i added the jacob.jar file to the classpath

But i still get a runtime error,

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:57)
    at com.jacob.com.JacobObject.<clinit>(JacobObject.java:150)
    at core.Index.main(Index.java:20)

Oh.. and placing the dll's in the c:/windows/system folder doesnt help

I have been searching the net , trying to figure out whats going wrong

please could you help me out


Share this post

Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...