Applescript:在用户在Apple Mail中输入密码之前,我如何停止脚本?

Applescript:在用户在Apple Mail中输入密码之前,我如何停止脚本?,applescript,Applescript,我的applescript在同步之前就挂断了,因为Apple Mail中存在一个错误,如果SMTP服务器与描述不匹配,它将再次要求输入密码。因此,用户必须输入密码并单击“确定”或“输入”,然后才会发生任何事情。 我有一个对话框提示,上面写着“在钥匙链中记住密码是一个好主意”,然后我让另一个提示在上面激活,这样他们就不能在没有输入密码的情况下单击“确定”…但这似乎不一致,而且很蹩脚。我宁愿找出一种不会出现提示的方法,或者我是否可以暂停脚本直到输入密码 --Activate Mail Applica

我的applescript在同步之前就挂断了,因为Apple Mail中存在一个错误,如果SMTP服务器与描述不匹配,它将再次要求输入密码。因此,用户必须输入密码并单击“确定”或“输入”,然后才会发生任何事情。 我有一个对话框提示,上面写着“在钥匙链中记住密码是一个好主意”,然后我让另一个提示在上面激活,这样他们就不能在没有输入密码的情况下单击“确定”…但这似乎不一致,而且很蹩脚。我宁愿找出一种不会出现提示的方法,或者我是否可以暂停脚本直到输入密码

--Activate Mail Application
tell application "Mail"
activate "Mail"
display dialog "Welcome to Mailbox setup with Google Mail. Please enter the password for your e-mail when prompted. This should not take any more than a minute."

delay 0.5

--Variables
--Creating account


set email_address to (short user name of (system info)) & "@EMAIL.com"
set full_name to (long user name of (system info))
set mailboxname to (long user name of (system info))
set shortname to (short user name of (system info))
set myPass to text returned of ¬
    (display dialog "Enter password for " & ¬
        quoted form of shortname ¬
        with title ¬
        "Gmail" with icon stop ¬
        default answer ¬
        "" buttons {"Continue…"} ¬
        default button 1 ¬
        giving up after 5 with hidden answer)


try
    set newacct to "imap.gmail.com"
    set newacct to make new imap account with properties {name:mailboxname, user name:email_address, password:myPass, uses ssl:true, server name:"imap.gmail.com", port:993, full name:full_name, email addresses:{email_address}}
    tell application "System Events" to key code 53

    --Create SMTP filter
    set addsmtp to "smtp.gmail.com"
    set addsmtp to make new smtp server with properties {server name:"smtp.gmail.com", user name:email_address, uses ssl:true, authentication:password, password:myPass}


    --Attach SMTP server
    set smtp server of newacct to addsmtp
    delay 1.0
    tell application "System Events" to tell process "Mail"
        set frontmost to true
        keystroke return
    end tell

    --Mailbox Sync
    delay 0.5
    on return
    tell application "Mail"
        synchronize with account mailboxname
    end tell

end try
end tell

您可以通过检查是否打开了一张工作表(在您的情况下为密码输入)来等待密码输入:

tell application "System Events"
    tell process "Mail"
        repeat until exists sheet 1 of window 1
            delay 0.1
        end repeat
    end tell
end tell

您可以通过检查是否打开了工作表(在您的情况下为密码输入)来等待密码输入:

tell application "System Events"
    tell process "Mail"
        repeat until exists sheet 1 of window 1
            delay 0.1
        end repeat
    end tell
end tell

前几天我也开始了这方面的工作。 据我所知,你应该和我有同样的问题。 当您告诉脚本设置新的SMTP服务器时,您必须声明

“身份验证:密码”

问题是这只是一个bug。 如果您在AppleCode中检查邮件库,它会声明“authentication”是“password”后缀的正确前缀

尽管如此,它每次都会抛出错误

我现在看不到任何工作,以前尝试过的人也看不到。
主要是垃圾

前几天我也开始了这项工作。 据我所知,你应该和我有同样的问题。 当您告诉脚本设置新的SMTP服务器时,您必须声明

“身份验证:密码”

问题是这只是一个bug。 如果您在AppleCode中检查邮件库,它会声明“authentication”是“password”后缀的正确前缀

尽管如此,它每次都会抛出错误

我现在看不到任何工作,以前尝试过的人也看不到。
主要是垃圾

有一个解决办法:

将身份验证设置为(“axct”为常量)

而不是这个

set authentication to password

有一个解决办法:

将身份验证设置为(“axct”为常量)

而不是这个

set authentication to password