Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Toggle web proxy settings via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Toggle web proxy settings via AppleScript
Authored by: RickoKid on Nov 23, '03 06:38:41PM
I got asked to update my script for Panther - here it is. This script chooses the right pane in System Preferences by using the System Preferences scripting interface rather tha GUI interface - bit faster! Here it is:
set proxyServer to "proxy.example.com"
set proxyPort to "3128"

tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.network"
end tell
tell application "System Events"
	get properties
	tell process "System Preferences"
		tell window "Network"
			click pop up button 2
			click menu item "Built-in Ethernet" of menu "OtherViews" of pop up button 2
			tell group 1
				tell tab group 1
					delay 1
					click radio button "Proxies"
					try
						click button "Click the lock to make changes." of window "Network" of process 
							"System Preferences" of application "System Events"
					end try
					tell group 1
						tell table 1 of scroll area 1
							set selected of row 2 to true
							click checkbox of row 1
							if value of (checkbox 1 of row 2) is 1 then
								set outStr to "Turned Web Proxy ON " & return 
									& "(set to '" & proxyServer & ":" & proxyPort & "')"
							else
								set outStr to "Turned Web Proxy OFF"
							end if
						end tell
						tell group 1
							set value of text field 2 to proxyServer
							set value of text field 1 to proxyPort
						end tell
					end tell
				end tell
			end tell
			click button "Apply Now"
		end tell
	end tell
end tell

ignoring application responses
	tell application "System Preferences" to quit
	display dialog outStr buttons {"Ok"} giving up after 2
end ignoring

---


RickoKid

[ Reply to This | # ]

Toggle web proxy settings via AppleScript
Authored by: efs on Mar 29, '04 10:31:01PM

I'm using 10.3.3 and this script bombed on me... right around the
[click menu item "Built-in Ethernet" of menu "OtherViews" of pop up button 2].

Before I play around with it -- considering I'm not too good at scripting yet -- has there been a menu change since this script was working for an earlier version of Panther?



[ Reply to This | # ]
Toggle web proxy settings via AppleScript (my error!)
Authored by: efs on Mar 30, '04 06:04:21PM

Apologies... misread RickoKid's posting about GUI scripting and thought it was no longer required... then looked at the code and saw I misread his comment, which only applies to activating network preferences.

It works fine. Blame the user (me). Thanks for the script!



[ Reply to This | # ]
Toggle web proxy settings via AppleScript
Authored by: s3pt1k on Aug 31, '05 01:52:42PM

Anyone have this script updated for Tiger?



[ Reply to This | # ]