on run {input, parameters} set userName to long user name of (system info) # User's full name set userHome to (system attribute "HOME") # User's home directory set secBin to "/usr/bin/security" # Full path to 'security' binary set kcName to "\"Zwift Login\"" # Keychain Name set kcPath to userHome & "/Library/Keychains/Zwift.keychain" # Path to where the Zwift keychain lives set mySedMess to "sed 's/.*\"acct\"=\"\\(.*\\)\"/\\1/'" # A horrible mess of sed. Nuff sed. # This is ugly, but it's the only way I could find to pull the account name from the Keychain. # Don't forget all of those escaping backslashes! (LTS - Leaning Toothpick Syndrome) set zUser to do shell script (secBin & " " & "find-generic-password 2>&1 /dev/null -gs " & kcName & " " & kcPath & " | grep acct | " & mySedMess) set zPass to do shell script (secBin & " " & "find-generic-password -wa " & zUser & " -gs " & kcName & " " & kcPath) activate application "Zwift" tell application "System Events" delay 3 # Wait for the login dialog to show up set frontmost of process "Zwift" to true # Force the Zwift process to the front keystroke tab # Put the cursor into the Email field keystroke zUser # Send the username (from above) keystroke tab # Jump to the Password field keystroke zPass # Send the password keystroke return # Press Enter to start the fun! end tell return input end run