Is it possible in AppleScript to switch to the second most recently used app (what pressing Cmd-Tab would do)? How would I got about doing this?
One way is to simulate Cmd+tab key presses, but I am not sure this would be fool proof and I wonder if there’s a better way
osascript -e 'tell application "System Events"
key down command
keystroke tab
key up command
end tell'