0

我有一个实现 WebView 对象的 Java GUI。WebView 加载 Google Docs,并将焦点设置在页面的文本编辑器部分。我还有一些 Applescript,它从对话框中获取文本输入并将变量设置wordString为输入文本的结果。我想知道是否可以将该文本发送到我的 GUI 应用程序?我似乎找不到任何有用的东西。

4

2 回答 2

0

在您的 java 应用程序中打开一个服务器套接字。看看Writing the Server Side of a Socket。在你的applescript中调用“nc”或“curl”来传递wordString

于 2012-07-11T14:01:10.660 回答
0

我实际上最终解决了这个问题。如果您的程序不可编写脚本,则需要做一些变通方法来完成一些脚本编写。我使用以下代码将文本发送到 Google Docs WebView:

tell application "System Events" to set frontmost of process "java" to true
tell application "System Events"
    tell process "java"
        keystroke newString --some text variable
    end tell
end tell

我从以下站点的示例中得到了这个:http: //www.makeuseof.com/tag/applescripts-ui-scripting-mac/

我还使用了一个程序,该站点建议使用它来识别 AppleScript 中使用的应用程序名称。该程序称为 UIElementInspector,可在http://mac.softpedia.com/get/Utilities/UIElementInspector.shtml找到

希望这对其他人也有帮助。

于 2012-07-11T20:46:10.283 回答