Script for 27" iMac Target Mode

So i have been playing with apple script since i got two imacs… I basically have been trying to get one to use command f2 30 seconds after boot to goto target display (so i dont need 2 keyboards) and i cant get it to work…

anyone have any ideas?

heres my cod.

tell me to delay 30
tell application "System Events" to keystroke "F2" using {command down}

Thanks!:slight_smile:

Try this:

delay 30
tell application "System Events" to key code 12 using command down

hope it works,
ief2

so basically this doesnt work :frowning: it needs the brightness up not the f2 after looking into it… i cant find a keycode for that :(((

this way won’t work at all. The AppleScript runner environment has not been loaded yet at boot time.
and even if it was available, sending key codes with System Events affects only applications with a GUI

it doesnt need it at boot, it could be pressed and used as a switch at any time… just command f2(bright up) i can do it with quickey’s but its bulky