OS X Messages Auto Reconnect Script

Ever had Messages disconnect in the background, only for you to find out that you’ve been offline for several hours? On a less-than-ideal Internet connection such as mine, this is a typical scenario. So much so that I came up with a script, which OS X Lion and Mountain Lion users can download below:

Messages Auto Reconnect.scpt (2KB, AppleScript)

Instructions

  1. Download the script above, uncompress it, and save the resulting .SCPT file to your ~/Documents folder (or wherever convenient).
  2. Launch Messages and go to Preferences (Command + ,).
  3. Under Alerts, select the When I Log Out event, and check Run an AppleScript script:.
  4. In the dropdown beside it, select Choose Script…; browse to, select and open the .SCPT file you saved.
  5. Close the Preferences window, and you should be good to go.

osx-messages-preferences-alerts

Below is the raw AppleScript, inspired by this Google Forums post:

using terms from application "Messages"
	
	on logout finished for theService
		if (connection status of theService is disconnected and status is not offline) then
			delay 1
			log in theService
		end if
	end logout finished
	
end using terms from

For some reason, it fails to differentiate between disconnected and offline, so you’ll need to quit Messages if you want to go offline. Other than that, it works perfectly for my needs.

Disclaimer

This script is provided as-is. Suggestions for fixes and improvements are welcome, but beyond that, I am unable to provide any support.

0 Responses to “OS X Messages Auto Reconnect Script”


Comments are currently closed.