(Mostly) Automated VPN login/logout #239
geofftaylor
started this conversation in
Show and tell
Replies: 1 comment
-
I love this!
…On Aug 6, 2022, 1:32 PM -0500, Geoff Taylor ***@***.***>, wrote:
This is my most-used and coolest Bunch. At work, I have to connect to multiple VPNs during the day. Our VPN client is Viscosity, which fortunately has a capable AppleScript dictionary. Using Bunch and AppleScript, I was able to mostly automate VPN login and logout.
It starts with this snippet called viscosity-login.snippet:
# Open Remote Desktop.
Microsoft Remote Desktop
# The only way to reliably make this do what I want is to break it up into 3 blocks of AppleScript.
# Connect to the VPN (passed as the connect_to variable by the calling bunch).
* tell application "Viscosity" to connect "${connect_to}"
# Set the Username field to my username, then set focus to the Password field.
* ```
tell application "System Events"
tell its application process "Viscosity"
set value of text field 1 of window 1 to "<my username>"
set focused of text field 2 of window 1 to true
end tell
end tell
```
# Wait 2 seconds, then activate Viscosity so that it has focus.
* tell application "Viscosity" to activate ~2
# Disconnect on close.
!* tell application "Viscosity" to disconnect "${connect_to}"
For each VPN, I have a bunch called "Connect to <VPN name>". The bunch calls viscosity-login.snippet and passes the connection name as the connect_to variable.
---
Title: Connect to <VPN name>
---
<viscosity-login.snippet
- connect_to = <VPN name>
I use separate bunches instead of a multiple choice dialog so that I can assign a hot key to each one in Keyboard Maestro. I have a macro for each VPN that just runs an AppleScript one-liner: tell application "Bunch Beta" to toggle bunch "Connect to <VPN name>"
When I need to log in, all I have have to do is run the appropriate bunch via a hot key and then enter my password and MFA code. To log out, I just close the bunch via the same hot key.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is my most-used and coolest Bunch. At work, I have to connect to multiple VPNs during the day. Our VPN client is Viscosity, which fortunately has a capable AppleScript dictionary. Using Bunch and AppleScript, I was able to mostly automate VPN login and logout.
It starts with this snippet called
viscosity-login.snippet
:For each VPN, I have a Bunch called
"Connect to <VPN name>"
. The Bunch callsviscosity-login.snippet
and passes the connection name as theconnect_to
variable.I use separate Bunches instead of a multiple choice dialog so that I can assign a hot key to each one in Keyboard Maestro. I have a macro for each VPN that just runs an AppleScript one-liner:
tell application "Bunch Beta" to toggle bunch "Connect to <VPN name>"
When I need to log in, all I have have to do is run the appropriate Bunch via a hot key and then enter my password and MFA code. To log out, I just close the Bunch via the same hot key.
Beta Was this translation helpful? Give feedback.
All reactions