Skip navigation

Can I use automator to type text?

1690 Views 14 Replies Latest reply: Dec 26, 2012 2:07 PM by Pierre L. RSS
Big Mike Level 1 Level 1 (55 points)
Currently Being Moderated
Dec 25, 2012 12:46 PM

I am looking for a way to fill in my email address in various types of online forms by using a shortcut. Can I use automator to insert an email address? If so, how? Is there a better way to do this, like an autocomple function? I am tired of typing my rather long email address everytime I need to insert it somewhere.

2i.5" iMac Intel Core 2 Duo; 13" MacBook, Mac OS X (10.6.4), 32 GB iTouch
  • BobHarris Level 6 Level 6 (12,480 points)
    Currently Being Moderated
    Dec 25, 2012 2:54 PM (in response to Big Mike)

    You might consider a product such as "TextExpander".  It is commercial, so maybe you could search <http://macupdate.com/find/mac/hotkey> for "hotkey" and maybe find a free hotkey text injection utility.

     

    Another approach might be to get 1Password, which will allow insertion of address, but more importantly it will manage your passwords for the 100's of web sites that you need to maintain an account at.  Very useful for those sites that should have a secure and different password from every other important site (banks, investments, on-line merchants that have your credit card info on file, etc...)

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 5:49 AM (in response to Big Mike)

    You might also run the following short script from the script menu. It should insert your email address into the insertion point of any selected text field :

     

    tell application "System Events" to keystroke "yourEmailAddress"

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 8:52 AM (in response to Big Mike)

    How do you run "System Events"? I clicked on the app but nothing happens. BTW, I am still running OS 10.6.8.

     

    The script should work without any problem under Mac OS X 10.6.8.

     

    The following steps are for OS X 10.8.2. I hope they are the same with Mac OS X 10.6.8.

    1. Open the AppleScript Editor application.

    2. Check the “Show Script menu in menu bar” checkbox in the AppleScript Editor general preferences.

    3. Copy and paste the one-line script from my previous post into the AppleScript Editor window.

    4. Save the script (file format: script) in the “Scripts” folder of your Library folder. Create the “Scripts” folder if it doesn't already exist.

    5. To run the script, just select it from the Script menu.

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 9:39 AM (in response to Big Mike)

    If I create a TextEdit document on my MacBook Pro and run the script as is, “yourEmailAddress” is first written at the beginning of the document, an then, if I run the script again, appended to the end of the previous text. Are you sure you have not inadvertently append your email address to the end of the script? Does your AppleScript Editor window looks like this?

     

    Capture d’écran 2012-12-26 à 12.21.58 PM.png

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 10:53 AM (in response to Big Mike)

    I tested the script on the old MacBook of my daughter, running Mac OS X 10.4.11. It didn't work with TextEdit until I modified it as follows. The first line isn't necessary under OS X 10.8.2, provided TextEdit is the frontmost application.

     

    tell application "TextEdit" to activate

    tell application "System Events" to keystroke "yourEmailAddress"

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 11:48 AM (in response to Pierre L.)

    The following script doesn't work under Mac OS X 10.4.11, but it works under OS X 10.8.2 and might work under Mac OS X 10.6.8. Would you like to try it?

     

    tell application "System Events" to get name of process 1 whose frontmost is true

    tell application result to activate

    tell application "System Events" to keystroke "yourEmailAddress"

     

    Message was edited by: Pierre L.

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 12:56 PM (in response to Big Mike)

    I'm glad I could help you. Many thanks for your feedback.

  • Hiroto Level 5 Level 5 (4,800 points)
    Currently Being Moderated
    Dec 26, 2012 1:30 PM (in response to Pierre L.)

    Hello Pierre L.

     

    The bundle identifier is safer than name because application's executable name is not necessarily equal to the package name minus extension. E.g. Firefox.app => firefox.

     

    --SCRIPT
    tell application "System Events" to get bundle identifier of process 1 whose frontmost is true
    tell application id result to activate
    tell application "System Events" to keystroke "hello"
    --END OF SCRIPT
    

     

    The code works fine under 10.5.8 as well.

    I guess the compatibility issue is due to the different implementations of Script menu and the different behaviours of AppleScript Runner (post-10.5) or System Events (pre-10.5) per OSes.

     

    All the best,

    H

     

    P.S. The script below (saved as application bundle) works fine under 10.4.11.

     

    --SCRIPT 2
    (*
        Save this as application bundle or application
        and invoke it from Script menu
    *)
    delay 0.1
    tell application "System Events"
        tell (process 1 whose frontmost is true) to set visible to false
    end tell
    delay 0.1
    tell application "System Events"
        tell (process 1 whose frontmost is true) to keystroke "hello"
    end tell
    --END OF SCRIPT 2
    

     

    /H

  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Dec 26, 2012 2:07 PM (in response to Hiroto)

    Hi Hiroto,

     

    Many thanks for your brilliant comments. It's always a pleasure to learn from you.

     

    PL

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.