Is there a way to create a script that will change the preferences of iChat to run the script when a message is received?
In other words,开发者_如何学编程 I want to make a script to change the iChat preferences to enable the "Message Received.applescript" i have created. Wow, this is confusing. Let me simply this.
I want a script that does this:
Activate iChat Open iChat Preferences Move to "Alerts" tab select event "Message Received" turn on "Run applescript" select a certain script from the script folder called "Message Receive.applescript"
please help?
You just need to edit iChat's plist file. defaults
is a bit awkward for nested values so use System Events instead:
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
This will attach "Message Received.scpt" to both initial text invitations and subsequent messages - you could simplify it if you only wanted it for subsequent messages. Also note you may need to relaunch iChat for the change to take effect.
精彩评论