2011-06-10 65 views
2

有没有一种方法可以创建脚本来改变iChat的偏好,以便在收到消息时运行脚本?用applescript更改iChat设置?

换句话说,我想制作一个脚本来更改iChat偏好设置,以启用我创建的“Message Received.applescript”。哇,这很混乱。让我简单地说一下。

我想一个脚本,做这样的:

激活的iChat 打开iChat偏好 移动到“警报”选项卡 选择事件“收到的消息”的“运行AppleScript” 转 选择从某个脚本脚本文件夹名为“Message Receive.applescript”

请帮忙?

回答

3

你只需要编辑iChat的plist文件。 defaults是一个有点尴尬的嵌套值,因此使用系统事件,而不是:

tell application "System Events" 
    set EventActions to property list item "EventActions" of property list file ((path to preferences folder from user domain as text) & "com.apple.iChat.plist") 
    repeat with e in {property list item "MessageNotification" of EventActions, property list item "SubsequentMessage" of EventActions} 
     make new property list item at end of e with properties {name:"RunAppleScript", value:true} 
     make new property list item at end of e with properties {name:"iChatAppleScriptsKey", value:{"~/Library/Scripts/iChat/Message Received.scpt"}} 
    end repeat 
end tell 

这将附上“消息Received.scpt”双方最初的文字邀请和后续消息 - 你可以把它简化,如果你只是想将其用于后续消息。另外请注意,您可能需要重新启动iChat才能使更改生效。

+0

我有这样的想法,只是不能让它编辑字符串 – 2011-06-18 03:11:03