如何使用Apple Script控制背光键盘?

Dav*_*vid 5 keyboard applescript

有没有办法使用Apple脚本来控制Macbook上背光键盘的亮度?

背光键是F5F6.

编辑:

基于@Clark我尝试过的建议,但它不起作用.

    NSAppleScript *run = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to key code 96"];
    [run executeAndReturnError:nil];
Run Code Online (Sandbox Code Playgroud)

有什么建议?

Cla*_*ark 1

Amit Singh 在 C 语言中有一章介绍如何做到这一点。

https://web.archive.org/web/20200103164052/https://osxbook.com/book/bonus/chapter10/light/

编译该页面上的示例代码并从 Applescript 调用它会很容易。

要使 Applescript 键入功能键,您必须使用键代码。功能键前面的按键代码是:

  • F1=122
  • F2=120
  • F3=99
  • F4=118
  • F5=96
  • F6=97
  • F7 = 8
  • F8=100
  • F9=101
  • F10=109
  • F11=103

要输入一个,请执行以下操作:

告诉应用程序“系统事件”键代码 96