user8143384
user8143384

Reputation: 25

How do I make an applescript that presses the delete key using command down

I have this script that I have been working on to clear out my Caches and application support files I will skip to the part that I need help with;


tell application "System Events"
    keystroke "o" using {command down}
        delay 0.5
    keystroke delete using {command down}
end tell

When the script gets to the keystroke delete using {command down} I get the error message;

error "System Events got an error: Can’t continue using." number -1708

How can I improve?

Upvotes: 2

Views: 5340

Answers (1)

jweaks
jweaks

Reputation: 3792

You use not keystroke, but the related key code to access special keys.

tell application "System Events"
    key code 51 using {command down}
end tell

See full reference of key codes here.

Upvotes: 11

Related Questions