【发布时间】:2014-08-26 15:15:17
【问题描述】:
为了让我的 VPN 连接保持活跃,我写了这个小脚本:
tell application "System Events"
tell network preferences
connect service "VPNServiceNameIConfigured"
end tell
end tell
这个脚本运行良好! 我给自己写了一个 lauchdeamon .plist 来在 StartUp、WakeUp 和每 5 秒调用一次脚本。这意味着,每次我的 vpn 连接中断时,它会每 5 秒自动重新连接(如果可能)。
这部分工作正常,但我想稍微改进一下。我想使用类似的 if-case
if network preferences service "VPNServiceNameIConfigured" is not connected
connect it
else do nothing
有没有办法做到这一点?如果是这样,我对使用 applescript 处理系统事件的示例或良好文档感到非常高兴。
谢谢!
【问题讨论】:
标签: if-statement applescript vpn