Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Messages.app (BETA) uses iChat syntax for AppleScript Apps
When looking at the new Messages.app preferences I realised that you can get it to run applescripts on various events.

Under the Alerts Tab in the Messages.app preferences, you will find a list of Events under the drop down Menu 'Event.' Each event has its own set of independent options . All include a 'Run an AppleScript script' option. These scripts can just run on every instance of the chosen event.

But you can interact with the Messages.app with the script the same way you would in iChat.

So if I wanted to, for example, have my Mac send me a message, when an event occurs that matches certain criteria I can use the iChat syntax.

Example:
using terms from application "iChat"
  
  on message received theMessage from theBuddy for theChat
    --display dialog (theBuddy's name as string)
    if theMessage is "some Text" then
      -- do something
        send "some info" to theBuddy
    else
      
      -- do something
      send "some other info" to theBuddy
    end if
  end message received
  
end using terms from
Messages.app at the moment registers itself as iChat, not Messages. This most likely will change when the final release is out.

I did not use iChat that much. But I will be using Messages.app a lot. What makes this even better is I can send Messages to myself to get my Mac to do things.

[crarko adds: I'm sure in Mountain Lion there will be some interesting ways to combine Notifications with Messages, if the Sandbox permits it.]
    •    
  • Currently 3.20 / 5
  You rated: 1 / 5 (5 votes cast)
 
[6,808 views]  

10.7: Messages.app (BETA) uses iChat syntax for AppleScript | 4 comments | Create New Account
Click here to return to the ' 10.7: Messages.app (BETA) uses iChat syntax for AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Messages.app (BETA) uses iChat syntax for AppleScript
Authored by: kcray on Feb 20, '12 09:29:00AM

Is there a way to send a message to a specific buddy rather then 'theBuddy' which is every incoming person. So say I get a message that says 'some Text' it would then send a response to a specific person rather then a reply the the person who sent 'some Text'.



[ Reply to This | # ]
10.7: Messages.app (BETA) uses iChat syntax for AppleScript
Authored by: mark hunte on Feb 22, '12 04:20:57PM
I think you can use the handle property

using terms from application "iChat"
	
	on message received theMessage from theBuddy for theChat
		--display dialog (theBuddy's name as string)
		if theMessage is "some Text" then
			-- do something
			set amate to buddies whose handle contains "amate@mac.com"
			
			send "test" to item 1 of amate
		else
			
			-- do something
			send "some other info" to theBuddy
		end if
	end message received
	
end using terms from
 
---
mh


[ Reply to This | # ]
10.7: Messages.app (BETA) uses iChat syntax for AppleScript
Authored by: Gobo on Feb 21, '12 01:33:08AM
I've been trying to send notifications to Growl from Messages, and it works somewhat, but I can't get the Buddy name from the event. Any help would be greatly appreciated. Here's what I have, this sends the content of the message to Growl as a notification:


using terms from application "iChat"
	
	on message received theMessage from theBuddy for theChat
		tell application "Growl"
			register as application 
				"Messages" all notifications {"Message"} 
				default notifications {"Message"} 
				icon of application "iChat"
			notify with name 
				"Message" title 
				"Message" description 
				theMessage application name "Messages"
			
		end tell
		
	end message received
	
end using terms from

Edited on Feb 21, '12 01:33:25AM by Gobo


[ Reply to This | # ]
10.7: Messages.app (BETA) uses iChat syntax for AppleScript
Authored by: mark hunte on Feb 22, '12 04:16:01PM
I did leave a clue in my original code. (name of theBuddy )
using terms from application "iChat"
	
	on message received theMessage from theBuddy for theChat
		tell application "Growl"
			register as application 
				"Messages" all notifications {"Message"} 
				default notifications {"Message"} 
				icon of application "iChat"
			notify with name 
				"Message" title 
				(name of theBuddy & " - Message") description 
				theMessage application name "Messages"
			
		end tell
		
	end message received
---
mh
---
mh
Edited on Feb 22, '12 04:16:43PM by mark hunte


[ Reply to This | # ]