Jump to content

_patrick

Member
  • Posts

    3
  • Joined

  • Last visited

Everything posted by _patrick

  1. Actually it looks like you can do it with a shell script. Alfred passes in the first param from the command to the script which is then inputted into the VPN prompt window if you're using 2 factor auth or a password or something. Here's the shell script from my workflow: on alfred_script(q) set theConnection to "My VPN Connection" -- Change this to the name of your VPN connection set connectionWindowTitle to "VPN Connection" set theApp to "UserNotificationCenter" set thePassword to q open_vpn_connection(theConnection, thePassword, theApp, connectionWindowTitle) end alfred_script -- Find a window containing specific static text, in a given application on find_window_by_static_text(appname, staticText) log "Searching " & appname & " for " & staticText tell application "System Events" set allApps to (get name of every application process) -- get all apps if allApps contains appname then -- find the app if it's running set allWin to (get every window of application process appname) -- get all the windows for our app set numWin to count allWin -- count the number of windows repeat with winNum from 1 to numWin set aWin to window winNum of application process appname set allText to (get value of every static text of aWin) if allText contains staticText then log "fwbst winnum: " & winNum return winNum end if end repeat end if end tell return null end find_window_by_static_text -- Open a given VPN connection and enter the password on open_vpn_connection(theService, thePassword, theApp, connectionWindowTitle) set scutilCommand to "scutil --nc start '" & theService & "'" do shell script scutilCommand if (thePassword is null) or (thePassword = "") then -- No need to do anything else with the window here... return null end if delay 2 repeat with x from 1 to 20 log "vc loop " & x delay 0.1 set winNum to find_window_by_static_text(theApp, connectionWindowTitle) log "winNum is: " & winNum if winNum is not null then exit repeat end if end repeat if winNum is null then display dialog "Could not find the VPN Connection window" return null end if tell application theApp to activate tell application "System Events" perform action "AXRaise" of item winNum of (get every window of application process theApp) keystroke thePassword key code 36 end tell end open_vpn_connection
  2. Yeah I assumed that was the case. Any idea if there is a work around of some sort?
  3. I'm trying to get the VPN window to pop up with El Capitan. This is the basic version of the code and it's just stopped working under 10.11. set theService to "Secure VPN Connection" tell application "System Events" tell network preferences connect service theService end tell end tell The weird thing is that if you change theService in that snippet to something that doesn't actually exist in your system then it will give you an error. If you just run the code with a valid value for theService then it returns null and doesn't give any error nor does it trigger the window to pop up. Any help would be appreciated.
×
×
  • Create New...