為同事開發的一個指令碼 用於快速切換 家裡跟單位的環境
tell application "System Events"
set proxy_dialog to display dialog "代理模組(Ethernet版本):" buttons {"開啟代理模式1", "開啟代理模式2", "關閉代理"} default button "開啟代理模式1"
with title "華夏基金開發環境快速切換代理App"
set proxy_interface to button returned of proxy_dialog
end tell
if proxy_interface is "開啟代理模式1" then
do shell script "networksetup -setwebproxy Ethernet 11.1.1.1 3128&&networksetup -setsecurewebproxy Ethernet 1.1.1.111 8080&&networksetup -setwebproxystate Ethernet on&&networksetup -setsecurewebproxystate Ethernet on" with administrator
privileges
end if
if proxy_interface is "開啟代理模式2" then
do shell script "networksetup -setwebproxy Ethernet 1.1.1.1 3128&&networksetup -setsecurewebproxy Ethernet 1.1.1.1 8080&&networksetup -setwebproxystate Ethernet on&&networksetup -setsecurewebproxystate Ethernet on" with administrator
privileges
end if
if proxy_interface is "關閉代理" then
do shell script "networksetup -setwebproxystate Ethernet off&&networksetup -setsecurewebproxystate Ethernet off" with administrator privileges
end if