我正在尝试使用 applescript 解锁系统偏好设置。
我设法让我的脚本单击“单击锁定以进行更改”部分,我试图让 applescript 输入用户名,但我一直收到错误
error "System Events got an error: Can’t get window 1 of process \"SecurityAgent\". Invalid index." number -1719 from window 1 of process "SecurityAgent"
这是我的代码,有人可以帮我吗?
activate application "System Preferences"
tell application "System Events"
set preferencesLocked to false
tell process "System Preferences"
delay 1
click menu item "Security & Privacy" of menu "View" of menu bar 1
delay 2.5
if title of button 4 of window 1 is "Click the lock to make changes." then
set preferencesLocked to true
click button "Click the lock to make changes." of window 1
end if
end tell
if preferencesLocked is true then
delay 2.5
activate application "SecurityAgent"
tell application "System Events"
tell process "SecurityAgent"
set value of text field 1 of scroll area 1 of group 1 of window 1 to "username"
end tell
end tell
end if
end tell
请帮忙。谢谢你。