如何使用AutoIT点击java摆动控制?
How to click java swing control using AutoIT?
我正在尝试使用 AutoIt 使我的 Java 应用程序自动化,但我在单击某些按钮时遇到困难。
我认为 AutoIt 知道控件在哪里,正如您在下面突出显示的那样,问题是它不会单击控件。
这是我的源代码...
String jacobDllVersionToUse;
if (System.getProperty("sun.arch.data.model").contains("32")) {
jacobDllVersionToUse = "jacob-1.18-x86.dll";
} else {
jacobDllVersionToUse = "jacob-1.18-x64.dll";
}
System.out.println(jacobDllVersionToUse);
File file = new File("autoit", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
String hWnd = "GfcEmulator-Hybrid";
String exeDir = "C:\GFC\resources\props";
String exeName = "GFCEmulator_Automation.jar";
Runtime.getRuntime().exec("cmd /c cd " + exeDir + " && " + exeName + "");
x.winActivate(hWnd);
x.winWaitActive(hWnd);
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:1]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:2]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:3]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:4]", "____________");
x.controlClick(hWnd, "", "[CLASS:ComboBox; INSTANCE:1]");
x.controlSend(hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "{down}+{enter}");
x.sleep(1000);
x.controlClick(hWnd, "", "[CLASS:Button; INSTANCE:1]"); // Click Connect Button, I already tried every method I know just to make this work but it all fails.
其他详情:
OS : Windows 10
按钮信息:
Auto IT 在 Java Swing
中检测控件有限制
我按照 AutoIT 论坛中的指南找到了解决方法:Java UDF
此 UDF 为 Java 应用程序提供自动化支持。
此 UDF 目前自动化独立应用程序和基于浏览器的小程序,它们是在 Swing 或抽象 Window 工具包 (AWT) 中开发的。
我正在尝试使用 AutoIt 使我的 Java 应用程序自动化,但我在单击某些按钮时遇到困难。
我认为 AutoIt 知道控件在哪里,正如您在下面突出显示的那样,问题是它不会单击控件。
这是我的源代码...
String jacobDllVersionToUse;
if (System.getProperty("sun.arch.data.model").contains("32")) {
jacobDllVersionToUse = "jacob-1.18-x86.dll";
} else {
jacobDllVersionToUse = "jacob-1.18-x64.dll";
}
System.out.println(jacobDllVersionToUse);
File file = new File("autoit", jacobDllVersionToUse);
System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());
AutoItX x = new AutoItX();
String hWnd = "GfcEmulator-Hybrid";
String exeDir = "C:\GFC\resources\props";
String exeName = "GFCEmulator_Automation.jar";
Runtime.getRuntime().exec("cmd /c cd " + exeDir + " && " + exeName + "");
x.winActivate(hWnd);
x.winWaitActive(hWnd);
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:1]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:2]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:3]", "____________");
x.ControlSetText(hWnd, "", "[CLASS:RichEdit20W; INSTANCE:4]", "____________");
x.controlClick(hWnd, "", "[CLASS:ComboBox; INSTANCE:1]");
x.controlSend(hWnd, "", "[CLASS:ComboBox; INSTANCE:1]", "{down}+{enter}");
x.sleep(1000);
x.controlClick(hWnd, "", "[CLASS:Button; INSTANCE:1]"); // Click Connect Button, I already tried every method I know just to make this work but it all fails.
其他详情:
OS : Windows 10
按钮信息:
Auto IT 在 Java Swing
中检测控件有限制我按照 AutoIT 论坛中的指南找到了解决方法:Java UDF
此 UDF 为 Java 应用程序提供自动化支持。
此 UDF 目前自动化独立应用程序和基于浏览器的小程序,它们是在 Swing 或抽象 Window 工具包 (AWT) 中开发的。