I'm following this tutorial: http://www.joecolantonio.com/2014/07/02/selenium-autoit-how-to-automate-non-browser-based-functionality/ to automate non-browser applications in Windows.
import java.io.File;
import autoitx4java.AutoItX;
import com.jacob.com.LibraryLoader;
import java.lang.System;
public class CalcTest {
/**
*
* Returns if the JVM is 32 or 64 bit version
*/
public static String jvmBitVersion(){
return System.getProperty("sun.arch.data.model");
}
public static void main(String[] args) throws InterruptedException {
String jacobDllVersionToUse;
if (jvmBitVersion().contains("32")){
jacobDllVersionToUse = "jacob-1.18-x86.dll";
}
else {
jacobDllVersionToUse = "jacob-1.18-x64.dll";
}
File file = new File("lib", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
x.run("calc.exe");
x.winActivate("Calculator");
x.winWaitActive("Calculator");
//Enter 3
x.controlClick("Calculator", "", "133") ;
Thread.sleep(1000);
//Enter +
x.controlClick("Calculator", "", "93") ;
Thread.sleep(1000);
//Enter 3
x.controlClick("Calculator", "", "133") ;
Thread.sleep(1000);
//Enter =
x.controlClick("Calculator", "", "121") ;
}
}
I get the following error:
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.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at autoitx4java.AutoItX.<init>(AutoItX.java:181)
at CalcTest.main(CalcTest.java:30)
The tutorial says that I should run regsvr32 C:\install\AutoItX\AutoItX3_x64.dll
in cmd but I keep getting the following error:
The module "C:\install\AutoItX\AutoItX3_x64.dll" was loaded but the call to DllRegisterServer failed with error code 0x80070005
I'm not sure what to make of this.
The following solution worked for me:
Copy AutoItX3_x64.dll
file. You can find it in C:\Program Files (x86)\AutoIt3\AutoItX
.
Paste it in C:\Windows\System32
.
Open a cmd prompt, run as administrator. Type regsvr32 AutoItX3_x64.dll
and press Enter.
You will get a message prompt as DllRegisterServer in AutoItX3_x64.dll succeeds.
I had to run cmd as an administrator. May as well leave this up. I'm sure someone might find themselves in the same boat one day...
Run as Administrator login in cmd and since you are using 64 bit os ,run it in the path C:\Windows\SysWOW64
and for 32 bit run in path ,C:\Windows\System32
--Swapna Mhatre
User contributions licensed under CC BY-SA 3.0