Skip to content

Instantly share code, notes, and snippets.

@johanforssell
Last active February 7, 2025 14:11
Show Gist options
  • Save johanforssell/a3e934e0a2a41ae34a9e5c2e5d1fc764 to your computer and use it in GitHub Desktop.
Save johanforssell/a3e934e0a2a41ae34a9e5c2e5d1fc764 to your computer and use it in GitHub Desktop.
Start Amazon AWS Client VPN and autopress the connect-button
-- Open the AWS Client VPN app and click the first button in the list.
-- Created because the app itself refuses to press the button on "enter" or "space".
--
-- Open this in "Script Editor", save as Application, start the new app and give it permission to "control your computer" under Accessibility in System Settings.
--
-- External dependency: 'cliclick' installed as `/opt/homebrew/bin/cliclick`!
-- brew install cliclick
-- Using this because I COULD NOT GET reliable clicking done with Apple Script >:-/
try
tell application "AWS VPN Client"
activate
-- Get the window position (top-left corner)
tell application "System Events"
tell process "AWS VPN Client"
set appWindow to first window
set {windowX, windowY} to position of appWindow
-- Calculate absolute coordinates
set clickX to windowX + 370
set clickY to windowY + 240
# display dialog "window position: " & windowX & ", " & windowY & " click position: " & clickX & ", " & clickY
#log "Attempting to click at: " & clickX & ", " & clickY
do shell script "/opt/homebrew/bin/cliclick -r c:" & (clickX as string) & "," & (clickY as string)
end tell
end tell
end tell
on error errMsg
display dialog "Error: " & errMsg
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment