Controlling Viscosity with AppleScript
Knowledge Base > Features > Controlling Viscosity with AppleScript
Viscosity provides AppleScript support, allowing VPN connections to be connected, disconnected, or their name and state listed, from AppleScript scripts.
Viscosity Suite
AppleScript Classes
- connection n : A connection.
Properties name (text, r/o) : The name of the connection. state (text, r/o) : The name of the connection.
Responds To connect, disconnect.
AppleScript Commands
- connect name : the name of the VPN connection to connect
- disconnect name : the name of the VPN connection to disconnect
Examples
Several examples of how you can interact with Viscosity using AppleScript have been included below.
Connect A Connection By Name
tell application "Viscosity" to connect "Home"
Disconnect A Connection By Name
tell application "Viscosity" to disconnect "Home"
Display Name Of The First Connection
tell application "Viscosity"
- set connectionName to name of the first connection
- display dialog connectionName
end tell
Display State Of The First Connection
tell application "Viscosity"
- set connectionState to state of the first connection
- display dialog connectionState
end tell
Action Depending On State Of The First Connection
tell application "Viscosity"
- if the state of the first connection is "Connected" then ...
end tell
Connect All Connections
tell application "Viscosity" to connectall
Disconnect All Connections
tell application "Viscosity" to disconnectall
|