苹果脚本--Automatically open the Messages chat window

Automatically open the Messages chat window 


I was annoyed by a behavior of Messages.app. When a friend sends me a message the chat window will not open automatically. Instead the Messages app icon will get a badge and bounce a couple of times in the dock. 

But if I'm not currently at the computer, and since I do not use the Dock to launch apps and I have the Dock always hidden, I could easily miss a message for a long time. So I came up with the following solution. 

First open /Utilities/AppleScript.app and paste the following into the script editor:

using terms from application "Messages"
	on message received theText from theBuddy for theChat
		set visible of window "Messages" to true
	end message received	
end using terms from
Pick a name and save the script in the scripts folder  ~/Library/Scripts

Next open up  /Applications/Messages.app  and do the following:
  • Under Preferences select Alerts.
  • Under Event select Received Message.
  • Tap Run an AppleScript and select your previously saved script under the Pop-Up menu.
Now when you receive a new message while you are away from the computer you have an open window with the message waiting for you. 

[ crarko adds:  I haven't tested this one. You need to be running 10.8 or later to have the Messages application, of course.]

你可能感兴趣的:(苹果脚本--Automatically open the Messages chat window)