System event key codes not working on thunderbolt display

applescriptterminalthunderbolt-displayunix

My AppleScript works when I am just using my MacBook Pro Retina, however if i have my Thunderbolt Display attached the script does not work.

Here is the script which works perfectly on just the laptop:

######## turn screen bright
repeat 25 times
    tell application "System Events"
        key code 113
    end tell
end repeat

Terminal will display this if i am running on the Thunderbolt Display:

^[[28~^[[28~^{{ (repeats)

Does any one know the key code to adjust brightness on the Thunderbolt Display or where I may find it?

Thanks in advance

Best Answer

Did you try key code 113 using control down? Pressing the brightness keys while holding control normally changes the brightness of a Thunderbolt Display, but I don't know if it works with keys like F15.

You can also use brightness.c to change the brightness of different displays:

do shell script "~/bin/brightness -d 1 0.0"