James
James

Reputation: 213

How to make finder run a keyboard shortcut in applescript?

This is my current code:

tell application "Finder"

    tell application "System Events" to keystroke "k" using {command down}

end tell

But it won't work.

Any tips?

Upvotes: 0

Views: 395

Answers (1)

markhunte
markhunte

Reputation: 6932

You do not tell the Finder to tell system events to do stuff.

You need to just make sure the Application that you want to intercept the keystrokes is active. Then tell System events to do the keystroke.

tell application "Finder" to activate
tell application "System Events"

    keystroke "k" using {command down}

end tell

Upvotes: 1

Related Questions