0
votes

I used an AppleScript in my OSX app to activate Finder and open up smb share folder with 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

It works well, but it does not work on one of my clients' Mac. The Finder doesn't activate, but the Finder menu bar on top of the screen shows.

I tried to use Script Editor on his Mac to execute the same script, still, Finder doesn't activate.

So far, this only occurred on this client's Mac. His Mac was running 10.10, upgraded to 10.11 but still out of luck.

Anyone has idea what happened? Is there any way you can 'disable' AppleScript?

1
GUI scripting is not enabled on your client’s Mac, but you do not need to use GUI scripting to script Finder, because it is natively scriptable, as noted in the answer below.Simon White

1 Answers

3
votes

Instead of trying to simulate Finder keyboard events, is there a specific reason why you are not just using instruction "open location" ?

The script bellow opens my smb shared volume :

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

Of course, your system may ask your login/password if it is not yet set in your keychain.