Reputation: 431
I have purchased Shimo - a VPN client for Mac OS X - and so far am very satisfied with it.
However, I use the service of VPNBook.com which provides free access to some of their VPN servers. The problem is that every 24 hours or so the password to all the free accounts change, the username remains the same.
Shimo offers an option to insert the username for each VPN connection so the only thing that has to be entered is the password.
I have an executable function that returns reads and returns the current password. So, if I run vpnpw
into the terminal, it prints the current working password.
The whole thing looks like this:
My plan is now to implement a script that, when Shimo asks for the password, automatically calls vpnpw
and inserts it into the prompt. Shimo offers triggers, for example running a shell script or an application when a connection is attempting to be established. So this should make things easier.
Here is a screenshot of how the prompt looks like (sorry for the German language):
What is the best way to do this? I thought about using Automator to run vpnpw
whenever the prompt is being displayed. However, I am not experienced with Applescript or Automator in general. Help would be much appreciated because I would like to automate this whole process.
Just for reference, I have attached my script returning the current VPN password for VPNBook.com under this link.
Upvotes: 0
Views: 1118
Reputation: 1767
You should be able to do something like this....
on run
set thePwd to do shell script "vpnpw"
set the clipboard to thePwd
end run
then I think you'll have to resort to GUI scripting
tell application "System Events"
keystroke "v" using command down
end tell
You'll need to enable UI scripting in your system preferences before this will work. You can see how/where to do that here
All said and done, your entire script could look something like this...
on run
set thePwd to do shell script "vpnpw"
set the clipboard to thePwd
tell application "Shimo" to activate -- You'll have to check this code, I don't have Shimo to know if this will work
do shell script "sleep 1" -- just to allow time for shimo to become the front app before the paste
tell application "System Events"
keystroke "v" using command down -- paste the clipboard
end tell
end run
Upvotes: 1