Cameron,Thank you for your post. Your script helped me figure out applescript a little bit. Using yours as a starting point I have crafted an applescript of my own that stops uTorrent in the event of vpn disconnection, reconnects the vpn and restarts uTorrent. I owe you one!Before: I left my computer downloading movies via uTorrent, and came home to find my vpn disconnected, uTorrent still running, and my IP being sprayed all over the place.After: The script below first connects my vpn of choice and opens uTorrent. Then it repeats the following indefinitely: watches the Tunnelblick connection every 1 second. If it is connected, it just keeps checking every second until it detects a disconnect. Upon disconnect, it quits uTorrent, reconnects the vpn connection via tunnelblick, and restarts uTorrent.tell application "Tunnelblick"
connect "config"
get state of first configuration where name = "config"
repeat until result = "CONNECTED"
delay 1
get state of first configuration where name = "config"
end repeat
if result = "connected" then run application "uTorrent"
end tell
repeat
tell application "Tunnelblick"
get state of configuration 1 whose name = "config"
if result = "connected" then repeat until result = "exiting"
delay 1
get state of configuration 1 whose name = "config"
end repeat
if result = "exiting" then quit application "uTorrent"
tell application "Tunnelblick"
connect "config"
get state of first configuration where name = "config"
repeat until result = "CONNECTED"
delay 1
get state of first configuration where name = "config"
end repeat
run application "uTorrent"
end tell
end tell
end repeat
"config" is replaced with my vpn of choice as it appears in the tunnelblick drop down menu. I was so excited that it worked, I had to share it.
Thanks again cameron, and a big thanks to the developer of tunnelblick!
-Ryan