首页 文章

AppleScript无法激活Finder

提问于
浏览
0

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

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,但仍然运气不好 .

谁知道发生了什么?有什么办法可以“禁用”AppleScript吗?

1 回答

  • 3

    而不是试图模拟Finder键盘事件,有没有一个特定的原因,你不只是使用指令“开放位置”?

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

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

    当然,如果您的登录名/密码尚未设置在您的钥匙串中,您的系统可能会询问您的登录名/密码 .

相关问题