2011-12-14 65 views
1

我的applescript挂起之前,它可以同步,因为在Apple Mail中的错误,如果SMTP服务器不匹配的描述,它会再次要求密码..因此,用户必须输入他们的密码,并点击确定或输入在任何事情发生之前。 我有一个对话框提示出现说:“在钥匙串中记住密码是一个好主意”,然后我有另一个提示激活它的顶部,以便他们不能点击确定,没有输入他们的密码......但似乎不一致和跛脚。我宁愿找出提示不会出现的方式,或者如果我可以暂停脚本直到输入密码。Applescript:如何在用户在Apple Mail中输入密码之前停止脚本?

--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 

Example

回答

1

您可以通过,如果一个表(在你的情况下,输入密码)被打开检查等待密码输入:

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

我对这个有一天开始工作以及。 据我所知,你应该和我有同样的问题。 当你告诉脚本来设置新的SMTP服务器时,必须声明

“身份验证:密码”

的问题是,这是很简单的错误。 如果您在AppleCode中检查邮件库,它会声明“身份验证”是“密码”后缀的正确前缀。

尽管如此,它每次都会引发错误。

我看不到任何工作在一分钟,也没有人曾经尝试过。 Majorly垃圾

2

有一种变通方法:

set authentication to ("axct" as constant)

set authentication to password 
代替
相关问题