使用 Cocoa ScriptingBridge 在 Adium 中创建新聊天
下面的 AppleScript 代码工作正常:
tell application "Adium" to tell first account to make new chat with contacts {first contact} with new chat window
但是我怎样才能使用 Cocoa 的 ScriptingBridge 做同样的事情呢?
The following AppleScript code works fine:
tell application "Adium" to tell first account to make new chat with contacts {first contact} with new chat window
But how can I do the same using Cocoa's ScriptingBridge?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,您应该能够按照 Apple 的 Cocoa 脚本桥编程指南。首先,我通过运行
sdef /Applications/Adium.app | 创建了 Adium 的头文件。终端中的 sdp -fh --basename Adium
(在当前目录中创建 Adium.h)。生成的头文件提供了有关通过脚本桥进行 AppleScript 调用的线索。我遇到的问题是,我无法根据生成的头文件找到一种方法来使用新的聊天窗口与联系人{...}进行新的聊天(我可以创建一个新的聊天窗口)(我可以创建一个新的聊天窗口)聊天,甚至可能将其挂接到新窗口中,但我找不到一种方法让该聊天接受联系人)。
下一个最好的办法可能是使用 NSAppleScript 执行有效的 AppleScript 代码:
Generally, you ought to be able to do it following Apple's Scripting Bridge Programming Guide for Cocoa. To start, I created a header file for Adium by running
sdef /Applications/Adium.app | sdp -fh --basename Adium
in Terminal (creates Adium.h in the current directory). The header file produced gives clues about making the AppleScript calls via the Scripting Bridge.The problem that I ran into is that I cannot see a way, based on the generated header file, to do
make new chat with contacts {...} with new chat window
(I can make a new chat and maybe even hook it into a new window, but I could not find a way to make that chat take the contact).The next best thing might be to use NSAppleScript to execute your valid AppleScript code:
如果不使用原始的 Apple 事件代码,您就不能。应该与 objc-appscript 一起使用。通过 appscript 的 ASTranslate 工具运行 AppleScript 命令会产生以下结果:
Short of using raw Apple event codes, you can't. Should work with objc-appscript though. Running your AppleScript command through appscript's ASTranslate tool produces the following: