Eclipse を使用して AutoIt を Java と統合しようとしています。プロジェクトとJavaビルドパスを適切に構成しました-おそらく;)。問題は、受け取ったプロジェクトを実行しようとしたときに、以下に示すエラーが表示されることです。
スレッド「メイン」com.jacob.com.ComFailException での例外: com.jacob.com.Dispatch.createInstanceNative(Native Method) at com.jacob.com.Dispatch.(Dispatch.java:99) でオブジェクトを共同作成できません) com.jacob.activeX.ActiveXComponent.(ActiveXComponent.java:58) で autoitx4java.AutoItX.(AutoItX.java:181) com.mainPackage.windowsGUIHandler.bleble(windowsGUIHandler.java:23) で com.mainPackage.windowsGUIHandler .main (windowsGUIHandler.java:39)
コード内のコードは次のようになります (非常に単純ですが、実行して AutoIT が機能するかどうかをテストするには十分です)
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();
}
}
調査を行ったところ、Eclipse が返された場合の対処法について説明しているこの記事を見つけました。オブジェクトを共同作成できませんが、cmd を入力すると
regasm /verbose /nologo /codebase C:\jacob-1.17-M2-x64.dll
このコマンドの後、エラーRegAsm : error RA0000 : Failed to load 'C:\jacob-1.17-M2-x64.dll' because it is not a valid .NET assembly が表示されます
さらに、JRE と JDK 6 x64 がインストールされた Windows 7 x64 で実行しています。