Skip to content

Archive for March, 2010

30
Mar

Using AppleScript to Automate an iChat Video Chat

I had to write a script to automatically start iChat at login and start a video chat with a specified screenname. I wanted to only start the chat if the user was online and available, and quit iChat on an error or if the chat ended. So here’s the script I have:

using terms from application "iChat"
	tell application "iChat"
		activate
		log in
		delay 5
		set theBuddy to buddy "ScreennameGoesHere" of service "AIM"
		try
			set theStatus to status of theBuddy
		on error errmesg number errno
			set message to display dialog "The user is currently unavailable." buttons {"OK"}
			quit
			return
		end try
		if theStatus is available then
			set theCapabilities to get capabilities of theBuddy
			if (theCapabilities contains multiperson video) then
				send "A user is attempting to contact you." to theBuddy
				delay 2
				tell service "AIM" to make video chat with properties {participants:theBuddy}
				set theChat to result
				delay 30
				try
					set theStatus to the av connection status of theChat
				on error errmesg number errno
					quit
					return
				end try
				repeat while theStatus is not ended
					delay 5
					try
						set theStatus to the av connection status of theChat
					on error errmesg number errno
						quit
						return
					end try
				end repeat
				quit
				return
			else
				set message to display dialog "The user cannot video chat at this time. Please try again later." buttons {"OK"}
				quit
				return
			end if
		else
			set message to display dialog "The user is currently unavailable." buttons {"OK"}
			quit
			return
		end if
	end tell
end using terms from

A couple of gotchas:

  • I tried using video chat instead of multiperson video, but that always returned false. I don’t know why.
  • Once the video chat has ended, you can’t poll its status (hence the try block).
9
Mar

New iPhone Project: uWarranty

So, I created a new iPhone application called uWarranty. It used an unpublished Apple API for warranty status (from selfsolve.apple.com), and so I got this after submitting it:

Thank you for submitting your application to the App Store. Unfortunately, your application, uWarranty, cannot be added to the App Store because it violates section 3.3.7 of the iPhone Developer Program License Agreement:

“Applications may not perform any functions or link to any content or use any robot, spider, site search or other retrieval application or device to scrape, retrieve or index services provided by Apple or its licensors, or to collect, disseminate or use information about users for any unauthorized purpose.”

OK, I get it. That’s fine and is Apple’s prerogative. But now I have this program and all the development time that went into it. So what do I do? I guess the answer is to open-source it, just like AppSales Mobile. Watch this space for more details as I clean up the code and throw it up on a public repository somewhere.

Jeff Kelley’s Blog is Digg proof thanks to caching by WP Super Cache