2011-06-10 64 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