Mac OS 10.10 Yosemite 如何在 AppleScript 中获取对话框焦点

How to get dialog box focus in AppleScript in Mac OS 10.10 Yosemite

我写了一个简单的脚本让 Active Directory 用户安装网络访问所需的特定钥匙串。我已经在10.7-10.9上成功使用了,指令提示也很好

当 10.10 出现时,"activate" 命令不再将程序带到前面。相反,在 Keychain Access 出现后,AppleScript 图标会在 dock 上疯狂地弹跳。

代码如下:

activate
display dialog "Welcome to the Mac Network Cerificate Installer (Version 6.0)" & return & return & "Click Okay to start installation of the Mac Network Certificate. Please wait until the next dialog box shows up." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"

delay 2

activate application "Keychain Access"

tell application "Finder" to open POSIX file "/Files/bn-virtualcar.crt"

delay 2

activate
display dialog "In the Keychain Access prompts, click the 'Add' then 'Always Trust'." & return & return & "After you have entered your password, close Keychain Access by clicking 'Keychain Access' in the top left corner and selecting Quit." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"

delay 2

tell application "System Events" to delete login item "Mac-Network-Cert"

How to ensure Applescript dialog focus in OS X 10.10 (Yosemite)? 上有一个类似的问题,但它对我不起作用,因为这些不是密码提示或 shell 脚本。我只想显示两个说明框。

如有任何帮助,我们将不胜感激。

你的对话框应该看起来像这样,以确保焦点,或者将它们粘贴到 Finder 告诉块。

tell application "SystemUIServer"
    activate
    display dialog "Welcome to the Mac Network Cerificate Installer (Version 6.0)" & return & return & "Click Okay to start installation of the Mac Network Certificate. Please wait until the next dialog box shows up." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"
end tell

delay 2

activate application "Keychain Access"

tell application "Finder" to open POSIX file "/Files/bn-virtualcar.crt"

delay 2
tell application "SystemUIServer"

    activate
    display dialog "In the Keychain Access prompts, click the 'Add' then 'Always Trust'." & return & return & "After you have entered your password, close Keychain Access by clicking 'Keychain Access' in the top left corner and selecting Quit." with icon file "System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:Bonjour.icns" buttons {"Okay"} default button 1 with title "WONK"
end tell
delay 2

tell application "System Events" to delete login item "Mac-Network-Cert"