iChat script

I would like to send a text message using ichat (the FILE/NEW CHAT WITH PERSON menu).
does anyone know the applescript command to do that ?

Model: powerbook 17" 1.67 - 2GB
Browser: Safari 412
Operating System: Mac OS X (10.4)

tell application "iChat"
	tell application "System Events"
		tell process "ichat" to set frontmost to true
		tell process "iChat" to click menu item 2 of menu "File" of menu bar 1
	end tell
end tell

when I excute it, it say: ‘System Events got an error: process not found.’ and the word frontmost is highlighted.

Model: powerbook 17" 1.67 - 2GB
Browser: Safari 412
Operating System: Mac OS X (10.4)

tell application "iChat"
activate
 tell application "System Events"
       tell process "ichat" to set frontmost to true
       tell process "iChat" to click menu item 2 of menu "File" of menu bar 1
   end tell
end tell

i get the same error. may be it is my set-up.

What about “send”?

you can send SMS through iChat only by going in the ‘File’ menu and selecting ‘New Chat with Person’. I actually wonder if this can be done directly using a command instead of using system events.

guardian34 did the script above work for you ?

I’m unable to test it, but you can try this:


tell application "iChat"
	activate
	send "SMS Test" to account "+10005551234" of service 1
end tell

It actually worked !!! thank you so much !!!
where did you learn to understand applescript and this ichat dictionary that looks incomprehensible to me.

I’m glad I could help.

Trial and error, basically.

I checked your web site and it looks like a windows technology site. So i was wondering if you use both mac and windows and what do you use applescript for ? thanks !

this is my script now:


tell application "iChat"
	activate
	log in
	delay 5
	send "SMS Test" to account "+19171112222" of service 1
end tell

i inserted a delay since sometimes it takes a while to log-in.
Do you know if there is a more elegant solution other then wait a fixed amount of time ?
may be wait until it logs in and if it doesn’t log in gives an error message or something.

thanks

I thought that this was exactly the script that I needed since it worked perfectly when I first tried it. However, when I changed to try another phone number II got: “iChat got an error: Can’t get account “+12545551212” of service 1.”

Any idea why. I hope to use a variation of this to send a short message to several phone numbers upon activation by another program - NOT FOR SPAM in case you are wondering. What are the conditions that have to be met for the receipent to get the message?

Riley Aldrich

This is also a good command line alternative:

http://pixelignition.net/applescript-sms-message-free

Don’t forget capitals in line 4

tell process "iChat" to set frontmost to true

I tried using this script, but the text does not get sent. The SMS window opens and accepts the phone number, but nothing is typed into the chat window. Seems to me that the Send SMS command should happen first, followed by the send “text” command. How would one do this?