Applescript - 相同
Applescript - Idein
我是 Appplescript 的新手。我需要在我的计算机上自动执行与蓝牙键盘相关的某些操作。
我希望能够在“系统偏好设置”面板的以下对话框 window 中单击键盘的删除或连接按钮。
Dialog window
到目前为止我的代码如下:
try
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell process "System Preferences"
click button "Set Up Bluetooth Keyboard…" of window "Keyboard"
end tell
end tell
tell application "System Events"
tell group 1 of window 1 of application process "System Preferences"
click button "remove" of "Home Keyboard"
end tell
end tell
end try
我的问题与删除按钮有关,因为它是未识别 table 的未识别单元格。身份不明,我的意思是没有描述。也许有一个简单的解决方案,但我找不到。此外,可能存在多个键盘,因此我需要从键盘名称中识别单元格。
您知道与此问题相关的任何提示吗?
提前致谢
这是我用来通过蓝牙重新连接特定鼠标的示例脚本:
tell application "System Events"
tell application "System Preferences"
activate
reveal anchor "MouseTab" of pane id "com.apple.preference.mouse"
end tell
tell application process "System Preferences"
click button "Configuration of Bluetooth mouse…" of window 1 -- see note 1
delay 1
select (first row of table 1 of scroll area 1 of sheet 1 of front window whose value of item 1 of static text of UI element 1 contains "Mouse") -- see note 1
get value of item 1 of static text of UI element 1 of row 2 of table 1 of scroll area 1 of sheet 1 of front window
click button "Done" of sheet 1 of front window -- see note 1
end tell
tell application "System Preferences" to quit
end tell
注意 1:注意带注释的 3 行 'see note 1':对于您的本地语言,字符串的值可能不同。请调整这 3 个值。
我觉得对于键盘来说,概念应该很相似。因为是使用GUI脚本,如果苹果改变了蓝牙屏幕首选项的布局,就必须进行调整。此脚本适用于 Yosemite 到 ElCaptain.I 无法针对下一个系统进行测试。
我是 Appplescript 的新手。我需要在我的计算机上自动执行与蓝牙键盘相关的某些操作。
我希望能够在“系统偏好设置”面板的以下对话框 window 中单击键盘的删除或连接按钮。
Dialog window
到目前为止我的代码如下:
try
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell process "System Preferences"
click button "Set Up Bluetooth Keyboard…" of window "Keyboard"
end tell
end tell
tell application "System Events"
tell group 1 of window 1 of application process "System Preferences"
click button "remove" of "Home Keyboard"
end tell
end tell
end try
我的问题与删除按钮有关,因为它是未识别 table 的未识别单元格。身份不明,我的意思是没有描述。也许有一个简单的解决方案,但我找不到。此外,可能存在多个键盘,因此我需要从键盘名称中识别单元格。
您知道与此问题相关的任何提示吗?
提前致谢
这是我用来通过蓝牙重新连接特定鼠标的示例脚本:
tell application "System Events"
tell application "System Preferences"
activate
reveal anchor "MouseTab" of pane id "com.apple.preference.mouse"
end tell
tell application process "System Preferences"
click button "Configuration of Bluetooth mouse…" of window 1 -- see note 1
delay 1
select (first row of table 1 of scroll area 1 of sheet 1 of front window whose value of item 1 of static text of UI element 1 contains "Mouse") -- see note 1
get value of item 1 of static text of UI element 1 of row 2 of table 1 of scroll area 1 of sheet 1 of front window
click button "Done" of sheet 1 of front window -- see note 1
end tell
tell application "System Preferences" to quit
end tell
注意 1:注意带注释的 3 行 'see note 1':对于您的本地语言,字符串的值可能不同。请调整这 3 个值。
我觉得对于键盘来说,概念应该很相似。因为是使用GUI脚本,如果苹果改变了蓝牙屏幕首选项的布局,就必须进行调整。此脚本适用于 Yosemite 到 ElCaptain.I 无法针对下一个系统进行测试。