Script to switch on a special Airport settings ?

Hello,

I am trying to find a script which can switch a special Airport settings. I’m on Tiger in Belgian French.

I do NOT have an airbase, I use only the airport card in my mac to allow my ipod to connect to internet through that “airport card/wifi link”.

For that I need to Share my ADSL link on Integrated Ethernet through Airport.

This can be made in System Preferences - Sharing (then Switch ON “Share personal Web” if it is off, if prefer to close it for security reason but normally that settings is kept) then in the Internet tab click the Launch/Start button, the settings are kept.
Then a dialog/sheet appears and ask a confirmation, click Start/launch.
Then Close System Prefs.

doooo…

The Share Personal Web must be on or it will not work.

I have no idea at all how to automate that… Anyone can help with this script ?

Thanks a lot :slight_smile:

I think I know how to do this in American English, and I’m hoping you can translate into Belgian French.

tell application "System Events"
	activate application "System Preferences"
	tell process "System Preferences"
		delay 0.2
		click menu item "Sharing" of menu "View" of menu bar 1
		delay 0.2
		click checkbox 1 of row 5 of table 1 of scroll area 1 of group 1 of window "Sharing"
		delay 0.2
		click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Sharing"
		delay 0.2
		click button "Start" of sheet 1 of window "Sharing"
		quit application "System Preferences"
	end tell
end tell

Everything in quotes needs to be localized, and I think the rest is OK staying in English.

Beiju, thanks so much !

Unfortunately, it has a problem, translation does not change the problem, using “Sharing” or “Partage”.
Increasing the delay to 1 does not change neither.

It opens the prefs, shows the Sharing panel.
Then an error message appears : “~Error in System Events : NSReceiverEvaluationScriptError: 4”, the line after the menu selection is highlighted.

tell application "System Events"
	activate application "System Preferences"
	tell process "System Preferences"
		delay 1
		click menu item "Partage" of menu "Présentation" of menu bar 1
		delay 1
		[b]click checkbox of row 4 of table 1 of scroll area 1 of group 1 of window "Partage"
		delay 0.2[/b]
		click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1 of window "Partage"
		delay 0.2
		click button "Démarrer" of sheet 1 of window "Partage"
		quit application "System Preferences"
	end tell
end tell

If you could give me a clue that would be nice. thanks again for your kind help ! :slight_smile:

The index of the checkbox is missing.
Here is a more reliable version, which works without delays.


tell application "System Preferences"
	activate
	reveal anchor "Internet" of pane id "com.apple.preferences.sharing"
end tell

tell application "System Events"
	tell process "System Preferences"
		tell table 1 of scroll area 1 of group 1 of window "Partage"
			tell (1st row whose value of static text 1 is "Partage web") to click checkbox 1
			tell (1st row whose value of static text 1 is "Partage Internet") to click checkbox 1
		end tell
		repeat until exists sheet 1 of window "Partage"
			delay 0.5
		end repeat
		click button "Démarrer" of sheet 1 of window "Partage"
	end tell
end tell
quit application "System Preferences"

Thanks a lot but this time, it goes a bit further, the internet tab is selected but then an Error occurs here *** see below *** that part is selected. The error message is : “~Error in System Events : NSReceiverEvaluationScriptError: 4”.

Thanks to all of you, the goal is getting closer :slight_smile:

tell application "System Preferences"
   activate
   reveal anchor "Internet" of pane id "com.apple.preferences.sharing"
end tell

tell application "System Events"
   tell process "System Preferences"
       tell table 1 of scroll area 1 of group 1 of window "Partage"
           tell (1st row whose value of static text 1 is "Partage web") to ***click checkbox 1***
           tell (1st row whose value of static text 1 is "Partage Internet") to click checkbox 1
       end tell
       repeat until exists sheet 1 of window "Partage"
           delay 0.5
       end repeat
       click button "Démarrer" of sheet 1 of window "Partage"
   end tell
end tell
quit application "System Preferences"

“Enable access for assistive devices” must be enabled in System Preferences > Universal Access

It is, the check box at the bottom of the first dialog…
Thanks a lot :slight_smile:

My previous answer does not seems very clear…

What I mean is that the checkbox was already ON but I still have the problem explained before.

Thanks for your help.

Two suggestions:

¢ Is “Partage web” misspelled?
¢ The script works in Leopard, the UI elements of Tiger are different

Thanks a lot for helping me like that :slight_smile:

Here is a huge capture of all the panels:
1 2 3
4 5

http://tex.dommel.be/partage.png


tell application "System Preferences"
	activate
	reveal anchor "Internet" of pane id "com.apple.preferences.sharing"
end tell

tell application "System Events"
	tell process "System Preferences"
		tell table 1 of scroll area 1 of group 1 of window "Partage"
			tell (1st row whose value of static text 1 is "Partage Web personnel") to click checkbox 1
			tell (1st row whose value of static text 1 is "Partage Internet") to click checkbox 1
		end tell
		repeat until exists sheet 1 of window "Partage"
			delay 0.5
		end repeat
		click button "Démarrer" of sheet 1 of window "Partage"
	end tell
end tell
quit application "System Preferences"

The third panel “Internet” is visible but it stops at the same place, on the first “… click checkbox 1” which is highligthed

When I do this, the last panel where “Démarrer/Start” is visible.

tell application "System Preferences"
	activate
	reveal anchor "Internet" of pane id "com.apple.preferences.sharing"
	
	get properties
end tell

I receive

{current pane:pane id "com.apple.preferences.sharing" of application "System Preferences", name:"System Preferences", frontmost:true, version:"3.3", class:application, show all:false, preferences window:window id 3686 of application "System Preferences"}

This might perhaps help you, if I set the “Keyboard and mouse” pref to “~Tab key jumps to ALL settings” to ON at the bottom of the window.

If I press TAB 3 times in the “Internet” panel, the focus is always on the button “Démarrer/Start”.