I'm trying to use Automator with AppleScript to automatically hit Command + F2 to enter Target Display Mode. The script runs but I just get a beep/tone with no action. I don't know if there's an error in the script or if it's not capable of hitting a function key.
on run {input, parameters}
tell application "System Events"
key down {command}
keystroke "120"
key up {command}
end tell
return input
end run
Once I get this working I'll need to somehow schedule this to run on startup or maybe on a schedule. I've seen some threads on this but never an actual solution. I'm using a 2011 iMac as a secondary monitor and hate hitting Command + F2 every day.