我对applecript很新,但我想我已经掌握了它的要点。我试图写一些启用/禁用从睡眠中唤醒时需要密码的东西,但我需要做的是获取返回的值并将其设置为可以在以后查看的变量。
tell application "System Events" to set security preferences's require password to wake to not (security preferences's require password to wake)
在结果中,显示真或假,这是我想要在对话框中显示的内容,但我要重新编写它。但是,我不知道如何取得结果的价值。问题是,由于需要密码唤醒是在一个告诉内部,我不知道如何检索它的布尔值。
我的整个剧本就是这样。我知道它可能非常混乱,但它几乎是我第一次获得苹果体验。
tell application "System Events" to set security preferences's require password to wake to not (security preferences's require password to wake)
tell application "System Events" to return security preferences's require password to wake as boolean
tell application "System Events" to return security preferences's require password to wake as boolean
if the "require password to wake" is false then display dialog (password_req as boolean)
if the "require password to wake" is false then display dialog (password_req as boolean)
if boolean = true then display dialog (boolean as text)
if boolean = false then display dialog (boolean as text)
get "require password to wake" as text
display dialog "require password to wake"
beep
display alert "Password toggled."
return
答案 0 :(得分:0)
tell application "System Events"
--note that this is a 'true tell block' as opposed to a one-liner
set security preferences's require password to wake to not (security preferences's require password to wake)
--above line can't return result. to do that you do:
set passReq to security preferences's require password to wake
end tell--block end
--ok, you've toggled it. now report it:
display dialog ("Password required is set to " & (passReq as text))