我编写了一个简单的脚本,让Active Directory用户安装网络访问所需的特定钥匙串。我已经在10.7-10.9上成功使用了它,并且指示提示很好。
当10.10出现时,"激活"命令没有把程序带到前面。相反,在Keychain Access出现之后,AppleScript图标就会在底座上疯狂地反弹。
以下是代码:
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脚本,因此对我不起作用。我只想要两个指示框出现。
任何帮助将不胜感激。
答案 0 :(得分:2)
您的对话框应如下所示,以确保对焦或坚持使用 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"