Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to use TextExpander to activate when I type the specific text "attached", and have the AppleScript type out the word "attached" (since TextExpander will remove it), and then invoke the keystroke Control-Z

I can get each to work individually, but not together. Here is the code I am using based off of code I found here:

    tell application "System Events"
    keystroke "attached"
    keystroke "z" using control down
    end tell
share|improve this question

1 Answer 1

I'm not sure what the TextExpander application name and process name is so I will guess.

activate application "TextExander"
    tell application "System Events"
        tell process "TextExpander"
            keystroke "attached"
            delay 0.5
            keystroke "z" using {command down}
        end tell
    end tell
share|improve this answer
For whatever reason, the "attached" text does not type out. The delay and the Ctrl-Z actions work fine. –  George C Nov 7 '12 at 15:34
If the edited version does not work, you may need to save it as an app, change the plist so it runs in the background and remove the tell process.. –  adayzdone Nov 7 '12 at 15:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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