Reputation: 14404
Is there a way to use an Apple Script to control the brightness of the backlit keyboard on a Macbook?
The backlit keys are the F5
and F6
.
Edit:
Based on the suggestion of @Clark
I tried the follow, but it does not work.
NSAppleScript *run = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to key code 96"];
[run executeAndReturnError:nil];
Any suggestions?
Upvotes: 6
Views: 3144
Reputation: 818
Amit Singh has a chapter on how to do this from C.
https://web.archive.org/web/20200103164052/https://osxbook.com/book/bonus/chapter10/light/
It'd be easy to compile the sample code on that page and call it from Applescript.
To make Applescript type a function key you have to use the key code. The key codes fore the function keys are:
To type one do something like this:
tell application "System Events" to key code 96
Upvotes: 1