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.
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...