Latest on twitter:
File: toggleinternetsharing.scpt
Language: Applescript
Download: http://gist.github.com/112789
Background: At work, I often share the Ethernet connection of my Macbook Pro over Airport, so that my iPhone can connect over Wi-Fi. However, at the end of the day, I switch Internet Sharing back off to free up the Airport, so that I can go online with my notebook wirelessly again on the go. I wanted a way to perform this task with just one click, and Applescript was my answer.
-- Internet Sharing Toggler: Toggle Internet Sharing on/off in OS X
-- 2009 May 16. Written for OS X 10.5.x.
-- Gordon Mei
-- Feel free to use and distribute however you'd like.
tell application "System Preferences"
activate
tell application "System Events"
tell process "System Preferences"
delay 0.5 --for running script again shortly after
click menu item "Sharing" of menu "View" of menu bar 1
delay 0.5
tell window "Sharing"
tell group 1
tell scroll area 1
tell table 1
tell row 10 --"Internet Sharing"
click checkbox 1
end tell
end tell
end tell
end tell
delay 0.5
if (exists sheet 1) then
tell sheet 1
click button "Start"
end tell
end if
end tell
end tell
delay 0.1
keystroke "w" using command down
end tell
end tell