Share internet (via wifi Airport) applescript

Alec Jacobson

July 17, 2011

weblog/

Here's an applescript we've been using at home to share the ethernet internet connection between our two laptops. The computer with the ethernet cord plugged in runs this script, then the other computer can connect to the wireless network of that computer's name and share its internet connection.
tell application "System Preferences"
	activate
end tell

tell application "System Events"
	tell process "System Preferences"
		click menu item "Sharing" of menu "View" of menu bar 1
		delay 2
		tell window "Sharing"
			if value of checkbox 1 of row 11 of table 1 of scroll area 1 of group 1 is 1 then
				click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
				click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
			end if
			
			
			click checkbox 1 of row 11 of table 1 of scroll area 1 of group 1
			delay 1
			if (exists sheet 1) then
				if (exists button "Turn AirPort On" of sheet 1) then
					click button "Turn AirPort On" of sheet 1
					delay 1
				end if
				click button "Start" of sheet 1
			end if
		end tell
	end tell
	tell application "System Preferences" to quit
end tell

Downloads

ShareInternet.app (zip) Here's a version wrapped into an app with a nice little icon so you can put it on your dock.