Passwords 使应用程序请求密码applescript

Passwords 使应用程序请求密码applescript,passwords,applescript,Passwords,Applescript,我正在尝试编写一个AppleScript代码,当我打开它时,Firefox会向我询问密码。这就是我得到的,但不知怎的它不起作用: on activate display dialog "Please enter your password" buttons {"Cancel", "Okay"} default answer "" default button 2 set x to text returned if x is "Password" then tell application

我正在尝试编写一个AppleScript代码,当我打开它时,Firefox会向我询问密码。这就是我得到的,但不知怎的它不起作用:

on activate
display dialog "Please enter your password" buttons {"Cancel", "Okay"} default answer "" default button 2
set x to text returned
if x is "Password" then
    tell application "Firefox"
        activate
        reopen
    end tell
else
    say "please try again"
end if
end activate

我还需要知道在脚本正确时将其保存在何处。非常感谢

将x设置为返回的文本时出现错误。它需要知道你指的是什么对话框。见下文

on activate
set passwordRequest to display dialog "Please enter your password" buttons {"Cancel", "Okay"} default answer "" default button 2
set x to text returned of passwordRequest

if x is "Password" then
    tell application "Firefox"
        activate
        reopen
    end tell
else
    say "please try again"
end if
end activate

下面是如何在你的脚本编辑器中粘贴它,然后保存为你想要的任何名称,但也保存为应用程序。当你这样做时,你可以将应用程序日志更改为你想要的,然后运行

on run
    set defaultanswer to display dialog "Please enter a passphrase to use this script." default answer "" with icon stop buttons {"Cancel", "Continue"} default button "Continue" with hidden answer
    set x to text returned of defaultanswer

    if x is "ANY PASSWORD U WANT" then
        tell application "ANY APPLICATION U WANT"
            activate
            reopen
        end tell
    else
        say "please try again"
    end if
end run

为什么?脚本无法阻止用户启动应用程序。操作系统基于每个用户帐户强制执行访问权限。如果您需要限制可以启动哪些应用,请创建一个新的标准用户帐户(或使用现有的来宾用户帐户,如果任何人都可以访问该帐户),然后使用“系统首选项”的“帐户”窗格中的“家长控制”选项根据需要对其进行配置。好的,谢谢。现在,我要将脚本保存在哪里,我要使用哪个扩展名?假设您使用的是脚本编辑器,请将它作为“应用程序”保存到您喜欢的任何位置。它会帮你处理扩展部分,但没用。当我点击Firefox时,它仍然没有问我密码就打开了。当我试着用语音识别打开它时,它根本没有打开。“一位客户要求我建立并安装一个定制的货架系统。我现在需要钉上它,但我不确定用什么钉进去。”另请参见。