bjo Posted October 18, 2006 Posted October 18, 2006 (edited) 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 October 19, 2006 by bjo
Richard Robertson Posted October 18, 2006 Posted October 18, 2006 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() { System.load("autoitx.dll"); } 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.
keewixi Posted June 16, 2007 Posted June 16, 2007 Hello, 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 { System.loadLibrary("AutoItX3"); } // 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 : System.out.println(AU3_PixelGetColor(100,100)); // 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.
Richard Robertson Posted June 17, 2007 Posted June 17, 2007 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.
keewixi Posted June 17, 2007 Posted June 17, 2007 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.
keewixi Posted June 17, 2007 Posted June 17, 2007 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...) try{ Runtime.getRuntime().exec("regsvr32.exe /s AutoItX3.dll"); } catch (IOException ex){ ex.printStackTrace(); } // Open notepad.exe ActiveXComponent AutoIt3 = new ActiveXComponent("AutoItX3.Control"); AutoIt3.invoke("Run","notepad.exe");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.
Richard Robertson Posted June 17, 2007 Posted June 17, 2007 Well, it should work regardless of the extension included or not. Java is just limited and kinda sucks when you try to use platform specific tools.
tommygun101 Posted June 22, 2007 Posted June 22, 2007 hey kewixi... i am using eclipse and i tried to run your example, in vm arguments in the run properties i added -Djava.library.path=<G:\mainpath\AutoItX3.dll> -Djava.library.path=<G:\mainpath\jacob.dll> 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 thanx
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