Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ezkimo

macrumors regular
Original poster
Sep 12, 2002
216
0
Hellooo,
So, I am trying to make an AppleScript that sends a message to userA when userB signs on. Since I am new to AppleScript, problems popped up pretty quickly.

Heres what I got:

property watchedUser : ""
on idle
tell application "iChat"
if status of account "userA" is available then
go(watchedUser)
quit
end if
end tell
return 10
end idle

on go(watchedUser)
set message to "online!"
tell application "iChat"
send message to account "userB"
end tell
end go

Since I want it hardwired to a specific configuration of people I can just change out the "userA" and "userB" for their actual screennames.

When I run the script it waits till userA has come online then says it cant continue to go (the send message part of the script)...any ideas?

Thanks!

Edit: To test it out I have been using the bots "Smarterchild" and "Infocombot" as the users if that helps
 
The problem seems to be something to do with nested "tell application "iChat"" blocks (since go is already in one when it's called). The following code appears to solve it. By the way, what are you using watchedUser for? Currently it isn't ever used except to parse it to go, which also doesn't use it.

Code:
property watchedUser : ""
on idle
	tell application "iChat" to set isAvailable to (status of account "userA" is available)
	if isAvailable then
		go(watchedUser)
		quit
	end if
	return 10
end idle

on go(watchedUser)
	set message to "online!"
	tell application "iChat"
		send message to account "userB"
	end tell
end go
 
HexMonkey said:
The problem seems to be something to do with nested "tell application "iChat"" blocks (since go is already in one when it's called). The following code appears to solve it. By the way, what are you using watchedUser for? Currently it isn't ever used except to parse it to go, which also doesn't use it.

I took a script for a completely different thing and modified it to come up with what I had. That script had the watched user thing and for some odd reason I was getting even less success without it...so I left it...AppleScript Newbie..

Thanks so much!
 
Actually, turns out that it dosnt work..I get a "NSRecieverEvaluationScriptError: 4" hmmmmmmmm
 
I got that error when I was first testing the script. From what I could tell, you get it if userA isn't on your buddy list and you're not having a chat with them. You also get a different error if userB isn't on your buddy list or isn't online when sending the message to them. So to fix the error, just make sure that userA is on your buddy list.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.