mac用AppleScript脚本连接南信大校园网
准备工具:
1.一台mac
2.脚本编辑器
3.校园网
每次开机,mac桌面都会弹出如下所示的校园网窗口。
每天都要反复去输入账号密码,很麻烦。不妨做一个简单的脚本,每次开机弹出此窗口,只需轻点脚本,即可连入校园网。
首先打开AppleScript
即上图 脚本编辑器
输入
tell application "System Events"
tell process "Captive Network Assistant"
tell window "加入“i-NUIST”"
tell scroll area 1 of group 1 of group 2
tell UI element 1
set value of attribute "AXFocused" of text field 1 to true
set value of text field 1 to "AAAAAAAAAA"
set value of text field 2 to "BBBBBBBBBB"
click pop up button 1
CCCC
delay 0.3
keystroke return
delay 0.5
click button "登 录"
delay 1
key code 13 using command down
end tell
end tell
click button 1
say "连接成功"
end tell
end tell
end tell
其中AAAA,BBBB,CCCC处需要你替换
- 将AAAA改为你的用户名
- 将BBBB改为你的密码
- CCCC对应了下图“南信大”“移动”“电信”“联通”四个选项。
需要将CCCC替换为
delay 0.2
key code 125
(每个key code125表示向下移动一行,而delay 0.2表示延迟0.2秒后再操作(否则可能让电脑的操作跟不上思维)。例如:如果你想选择南京信息工程大学,则直接将CCCC删去即可;如果你是中国联通的,将CCCC换为如下方代码即可。)
delay 0.2
key code 125
delay 0.2
key code 125
delay 0.2
key code 125
导出为程序,放在桌面
下次看到校园网弹窗,只要点击它⬇️就OK了
如果你懒得点击,可设置为自动运行,具体操作这里不再赘述。