1

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.

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Mister S
  • 203
  • 1
  • 7
  • 14

1 Answers1

0

Are you using Windows 7 32 bit in a 32 bit processor machine or Windows 7 64 bit in a 64 bit machine.

I tried registering the jacob-1.17-M2-x86.dll in my Windows 7 32 bit in a 32 bit processor machine with regsvr32 and it worked successfully

but in my another machine with Windows 7 64 bit in a 64 bit processor machine neither jacob-1.17-M2-x86.dll or jacob-1.17-M2-x64.dll got registered successfully.

and I had to use AutoItX3.dll which gets downloaded with latest AutoIT installation.

Check your configuration and try the correct files and see.