Automator and/or AppleScript to automatically Command-F2 to enter Target Display Mode
keystroke "120" is not the same as key code 120; the former taps the keys 1, 2, and 0.

I've had success with the following AppleScript, but you can also try key code 120 and key code 113.

tell application "System Events" to key code 144 using command down