【发布时间】:2015-08-04 06:52:50
【问题描述】:
我的最终目标是在后台启动系统偏好设置,进入听写和语音,更改听写语言,然后退出系统偏好设置。一切都在后台,没有人看到。
目前我的代码是:
tell application "System Preferences" to launch
delay 1
tell application "System Events" to tell process "System Preferences"
click menu item "Dictation & Speech" of menu "View" of menu bar 1
tell pop up button 1 of tab group 1 of window 1
click
if value is "English (United States)" then
click menu item "Chinese (China)" of menu 1
else
click menu item "English (United States)" of menu 1
end if
end tell
end tell
quit application "System Preferences"
我注意到,如果在某些时候我将系统偏好设置为焦点/作为选定的顶级进程,这将起作用。之后,可以选择任何应用程序,并且此代码将起作用。或者,如果我将“启动”更改为“激活”,它将起作用(但这违背了我的目的,因为它会将系统偏好设置放在顶部)
但是,如果在系统偏好设置尚未启动时运行,我的代码将不工作。就像系统在选择/激活之前对应用程序及其菜单一无所知。
我需要改变什么?
谢谢。
【问题讨论】:
标签: macos applescript