I'm trying to integrate AutoIt with Java using Eclipse. I have configured project and java build path properly - probable ;). The problem is that when I tried to run the project I've received and error presented below:
Exception in thread "main" com.jacob.com.ComFailException: Can't co-create object at com.jacob.com.Dispatch.createInstanceNative(Native Method) at com.jacob.com.Dispatch.(Dispatch.java:99) at com.jacob.activeX.ActiveXComponent.(ActiveXComponent.java:58) at autoitx4java.AutoItX.(AutoItX.java:181) at com.mainPackage.windowsGUIHandler.bleble(windowsGUIHandler.java:23) at com.mainPackage.windowsGUIHandler.main(windowsGUIHandler.java:39)
My code in code looks like that (quite simple but enough to run and test if AutoIT works)
package com.mainPackage;
import java.io.File;
import com.jacob.com.LibraryLoader;
import junit.framework.Assert;
import autoitx4java.AutoItX;
public class windowsGUIHandler {
public static void thisIsTestFunction() {
File file = new File("lib", "jacob-1.17-M2-x64.dll");
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
LibraryLoader.loadJacobLibrary();
AutoItX x = new AutoItX();
String notepad = "Untitled - Notepad";
String testString = "this is a test.";
x.run("notepad.exe");
x.winActivate(notepad);
x.winWaitActive(notepad);
x.send(testString);
Assert.assertTrue(x.winExists(notepad, testString));
x.winClose(notepad, testString);
x.winWaitActive("Notepad");
x.send("{ALT}n");
Assert.assertFalse(x.winExists(notepad, testString));
}
public static void main(String[] args) {
thisIsTestFunction();
}
}
I made a research and I have found this article which describes what to do if eclipse returns Can't co-create object but when I type in cmd
regasm /verbose /nologo /codebase C:\jacob-1.17-M2-x64.dll
After this command I get an error RegAsm : error RA0000 : Failed to load 'C:\jacob-1.17-M2-x64.dll' because it is not a valid .NET assembly
In addition I'm running on Windows 7 x64 with JRE and JDK 6 x64 installed.