Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

activate application "TextExpander"
    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

TextExpander has its own script-ability.



tell application "Alfred 2"
    search ""
    tell application "TextExpander"
        expand abbreviation ";drmt"
    end tell
end tell
share|improve this answer

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.