Turn on and off Internet Sharing
Hi
I'm new in Applescript and want to write script which turn on and off my Internet Connection sharing. So I wrote something like this:
tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
tell application "System Events" to tell process "System Preferences"
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 0 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
else
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 1 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
delay 1
tell application "System Preferences" to quit
end if
end if
end tell
Turn off Connection Sharing works fine - it's start System Preferences, turn off Conncection Sharing and quit System Preferences.
But if I try to turn on Connection Sharing there is window appear with message something like (I have Polish OS X so forgive me inaccurate translation): Are you sure want to turn on internet connection sharing. with 2 buttons: Run (Start) and Cancel.
And now... How to write further part of my script which click Run (start) button and quit System Preferences panel?
Thanks for any advices
Message was edited by: fascik
I'm new in Applescript and want to write script which turn on and off my Internet Connection sharing. So I wrote something like this:
tell application "System Preferences" to set current pane to pane "com.apple.preferences.sharing"
tell application "System Events" to tell process "System Preferences"
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 0 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
else
if value of checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing" is 1 then
click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
delay 1
tell application "System Preferences" to quit
end if
end if
end tell
Turn off Connection Sharing works fine - it's start System Preferences, turn off Conncection Sharing and quit System Preferences.
But if I try to turn on Connection Sharing there is window appear with message something like (I have Polish OS X so forgive me inaccurate translation): Are you sure want to turn on internet connection sharing. with 2 buttons: Run (Start) and Cancel.
And now... How to write further part of my script which click Run (start) button and quit System Preferences panel?
Thanks for any advices
Message was edited by: fascik
MacBook, Mac OS X (10.5.6)