# Alfred as Text Expander

## Recommended Posts

Hi

Just wondering if it will be possible to extend the use of "Copy to Clipboard" (Paste to front most app) to feature special keys like Return, Tab and such, and thereby making Alfred an awesome Text Expander?

I have seem some workflows with scripts doing this, but would be nice build in.

http://d.pr/i/vPrW

##### Share on other sites

Hi Simzdk,

Any line breaks and tabs will be preserved just by entering the text "as is".

^^^ That works fine when pasting.

##### Share on other sites

I'm not quite sure what you're trying to achieve? Why not simply use returns and tabs in there?

##### Share on other sites

Im looking for simple Text Expander functionality. Say I want to quickly fill out a address form on a webpage. I would focus the cursor in the first field, active Alfred, and Alfred would paste my name first, Tab to get to another field, paste test into that and so on.

Tab works in Textmate but doesn't jump between html fields in a webpage.

##### Share on other sites

At this point, this is fairly unlikely as this would get to depths comparable to Text Expander and would be complex enough to be its own app. You could have a play around with scripts but for now, I'll say unlikely.

##### Share on other sites

David,

That is what I tried, but still dont work in websites.

##### Share on other sites

I use it daily. There must be some step that you are missing.

My use case:

1. Create the keyword. For this example, we'll say I'm creating one for my name. So I would set the keyword to be ',df'.

2. Create the Copy to Clipboard output item. Set the data to be copied to be 'David Ferguson'. Set the option to paste to front app.

3. Connect the keyword to the copy to clipboard output.

4. Go to web, apps, etc

5. Cmd+Space to pop up Alfred

6. Type ',df' and press Enter.

I used this exact method to expand ',df' into 'David Ferguson' above, and right here. So it works in browsers/in forms.

##### Share on other sites

And by using the tab key in the paste field, you can get Alfred to jump between two input text field in a html page? I cant seem to get that working.

If I use the workflow in a pure text field like this, I can see the tab in the text, but it doesnt read as a tab (special key) so it wont jump fields.

##### Share on other sites

Let me try to create an example. Here you have 2 html fields. I want to create a workflow that input value in both.

Here is a test-workflow, with a "tab" between "Field 1" and "Field 2"

http://d.pr/i/U3mB

However it looks like this when used.

http://d.pr/i/B172

Hope this makes sense.

##### Share on other sites

What you're looking at doing is using Alfred as a form filler and not a text expansion. These are completely different. Also, something like that is going to be something that is a little more difficult to do because of the fact that web forms are so different. Some have name and email only, some have name, email, address (with 1, 2, or 3 lines), city, state, etc. You CAN do this, but it has the potentially to be wildly inaccurate because of changing forms. To do it would require the use of AppleScript and not using the clipboard. You would have to simulate keystrokes with AppleScript, telling it to keystroke "text", keystroke "Tab", keystroke "text", etc.

##### Share on other sites
• 1 month later...

I use it daily. There must be some step that you are missing.

My use case:

1. Create the keyword. For this example, we'll say I'm creating one for my name. So I would set the keyword to be ',df'.

2. Create the Copy to Clipboard output item. Set the data to be copied to be 'David Ferguson'. Set the option to paste to front app.

3. Connect the keyword to the copy to clipboard output.

4. Go to web, apps, etc

5. Cmd+Space to pop up Alfred

6. Type ',df' and press Enter.

I used this exact method to expand ',df' into 'David Ferguson' above, and right here. So it works in browsers/in forms.

Thanks for this David - it works great and I now think I'll give Typeit4Me the flick and have one less app to load and take space in the menubar. Regarding your comment about not being a solution as a form filler - I suppose there's also no way to auto insert the date or time (e.g. dt, tm) as with the purpose built text expanders?

Thanks

##### Share on other sites

I suppose there's also no way to auto insert the date or time (e.g. dt, tm) as with the purpose built text expanders?

##### Share on other sites

Hi David Ferguson,

Isn't it too much work setting up text expansions inside workflows? I prefer to use the clipboard snippets built-in feature: It works the same way, it's faster to create a snippet, it lets you set a keyword to do the expansion, and it has a separate keyboard shortcut - so your keywords don't conflict with the rest of the stuff, and you don't even need to set a prefix, like "," before the expansion.

I only see the need for a workflow if there is some kind of processing involved, like settings arguments or so

Edited by thiagoaraujos
##### Share on other sites

Hi David Ferguson,

Isn't it too much work setting up text expansions inside workflows? I prefer to use the clipboard snippets built-in feature: It works the same way, it's faster to create a snippet, it lets you set a keyword to do the expansion, and it has a separate keyboard shortcut - so your keywords don't conflict with the rest of the stuff, and you don't even need to set a prefix, like "," before the expansion.

I only see the need for a workflow if there is some kind of processing involved, like settings arguments or so

Snippets do indeed work just as well. The only reason that I personally chose Workflows over snippets was because of the additional space required to use a snippet. For example, with snippets the usage to expand my name would be (by default) '; df'. Notice the space between. I moved from DashExpander and TextExpander and was used to something more like ',df', without the space. Workflows allowed me to do that. So yeah, snippets do it and are probably better suited for it, it was all just a personal preference. And I think at the time I started setting that up and playing with it, I'm wanting to say that snippets and the clipboard history for Alfred 2 had not been finished yet

##### Share on other sites
• 11 months later...

I have a file with abbreviation and desired expansions, for example for may LaTeX documents. I have it in Textmate and In there I can expand using this list. Do you think it is possible to make alfrd to read a list like this:

;a  \alpha

;b  \beta

;thm  \begin{theorem} %| \end{theorem}

... ?

and not to have to do every single abbreviation by hand?

For example I can export my TextExpander snippets in to a single document (a list). It would be perfect If I can just make Alfred to use the list to expand my snippets.

Edited by Yoyontzin
##### Share on other sites

Going back to the original point of inserting ⇥, ↩, and others, it is fairly easy with applescript. Take into account, however, this will be like pressing the keys without any checking, so it can lead to undesirable results.

As an example, if you want to fill your first name, press ⇥ to go to the next field, and fill in your last name, you could have a Run Script node using /usr/bin/osascript as the language, and write something like

tell application "System Events"
keystroke "<your_first_name>"
key code 48
keystroke "<your_last_name>"
end tell


key code 48 is ⇥, naturally. Something like Key Codes will help you find other codes you might need.