我试图编写一个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
我还需要知道在正确的情况下保存脚本的位置。非常感谢!
答案 0 :(得分:0)
set x to text returned
出错。它需要知道你指的是什么对话。见下文。
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
答案 1 :(得分:-1)
这里将其粘贴到脚本编辑器中,然后保存为您想要的名称,同时还保存为应用程序,您可以将应用程序日志更改为所需的名称,然后运行
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