gpt4 book ai didi

windows - 线程 "main"com.jacob.com.ComFailException : Can't co-create object 中的异常

转载 作者:可可西里 更新时间:2023-11-01 11:48:30 26 4
gpt4 key购买 nike

我正在学习本教程:http://www.joecolantonio.com/2014/07/02/selenium-autoit-how-to-automate-non-browser-based-functionality/在 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") ;
}

}

我收到以下错误:

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)

教程说我应该在 cmd 中运行 regsvr32 C:\install\AutoItX\AutoItX3_x64.dll 但我一直收到以下错误:

The module "C:\install\AutoItX\AutoItX3_x64.dll" was loaded but the call to DllRegisterServer failed with error code 0x80070005

我不知道该怎么做。

最佳答案

以下解决方案对我有用:

  1. 复制 AutoItX3_x64.dll 文件。您可以在 C:\Program Files (x86)\AutoIt3\AutoItX 中找到它。

  2. 将其粘贴到C:\Windows\System32

  3. 打开 cmd 提示符,以管理员身份运行。键入 regsvr32 AutoItX3_x64.dll 并按 Enter

  4. AutoItX3_x64.dll中的DllRegisterServer注册成功,会有提示

关于windows - 线程 "main"com.jacob.com.ComFailException : Can't co-create object 中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37141288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com