AppleScript 无法激活 Finder

AppleScript can not activate Finder

我在我的 OSX 应用程序中使用了 AppleScript 来激活 Finder 并使用 smb 打开 smb 共享文件夹 URL。

     set the clipboard to "smb://192.168.99.99"
         tell application "Finder"
         activate
     end tell
     delay 0.5
     tell application "System Events"
         keystroke "k" using command down
     end tell
     delay 0.2
     tell application "System Events"
         keystroke "v" using command down
         keystroke return
     end tell

它运行良好,但不适用于我的一位客户 Mac。 Finder 未激活,但屏幕顶部的 Finder 菜单栏显示。

我尝试在他的 Mac 上使用脚本编辑器来执行相同的脚本,Finder 仍然没有激活。

到目前为止,这只发生在这个客户的 Mac 上。他的 Mac 是 运行 10.10,升级到 10.11 但仍然不走运。

有人知道发生了什么事吗?有什么方法可以 'disable' AppleScript?

而不是尝试模拟 Finder 键盘事件,是否有特定原因导致您不只是使用指令 "open location"?

下面的脚本打开我的 smb 共享卷:

set MyAddress to "smb://192.168.99.99"
open location MyAddress

当然,您的系统可能会询问您的 login/password 是否尚未在您的钥匙串中设置。