我正在寻找使用 Java/JACOB 获取 powerpoint 窗口的本机窗口句柄。MSDN 文档似乎表明应该可以只获取“ HWND”属性,所以我正在尝试这样:
app = new ActiveXComponent("PowerPoint.Application");
Dispatch presentations = app.getProperty("Presentations").toDispatch();
presentation = Dispatch.call(presentations, "Open", fileLocation).toDispatch();
EnumVariant windows = new EnumVariant(Dispatch.get(presentation, "Windows").toDispatch());
Dispatch window = windows.nextElement().toDispatch();
Dispatch.get(window, "HWND"); //Exception here
但是,我似乎无法以这种方式获取窗口句柄 - 我收到以下错误:
Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: HWND
Description: 80020003 / Member not found.
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.get(Dispatch.java:788)
at tester.PowerpointSlideShowRunner.<init>(PowerpointSlideShowRunner.java:54)
at tester.PowerpointSlideShowRunner.main(PowerpointSlideShowRunner.java:154)
这是图书馆中的错误,还是我在这里做错了什么/误解了什么?后者很有可能,因为我对雅各布完全陌生。无论哪种方式,我应该如何使用 JACOB 获取 Powerpoint 窗口的 HWND?