2

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?

1
  • You are mixing up AppleScript terminology with key codes. The AS delete command does not respond to key modifiers. Why do you use (a sort of) GUI scripting rather than deleting the files directly?
    – vadian
    Jun 11, 2017 at 5:01

1 Answer 1

11

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.