14 Replies Latest reply: Dec 26, 2012 2:07 PM by Pierre L.
Big Mike Level 1 Level 1 (55 points)

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
  • 1. Re: Can I use automator to type text?
    BobHarris Level 6 Level 6 (13,120 points)

    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...)

  • 2. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    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.

  • 3. Re: Can I use automator to type text?
    Big Mike Level 1 Level 1 (55 points)

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

  • 4. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    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.

  • 5. Re: Can I use automator to type text?
    Big Mike Level 1 Level 1 (55 points)

    Sorry for being difficult. I followed your steps and created a scipt called "Insert online email" which is now under user scripts in the scripts menu bar dropdown. I then created a TextEdit document and ran the script. Nothing happens. There must be another step that I need.

  • 6. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    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.

  • 7. Re: Can I use automator to type text?
    Big Mike Level 1 Level 1 (55 points)

    Yes, my script looks exacrtly like your screen shot:

    file://localhost/Users/marx%201/Desktop/Screen%20shot%202012-12-26%20at%201.00.4 5%20PM.png
    Do I need to define "yourEmailAddress"? If I change this to my email address still nothing happens.
    Thanks for the ongong help.

  • 8. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    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"

  • 9. Re: Can I use automator to type text?
    Big Mike Level 1 Level 1 (55 points)

    Ok, but is there a way to have this script work with any active application? I might be in any of a number of apps or browsers when I need to insert my email address; most likely a form of some sort.

  • 10. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    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.

  • 11. Re: Can I use automator to type text?
    Big Mike Level 1 Level 1 (55 points)

    That works with OS 10.6.8.

    Thanks Pierre.

  • 12. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

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

  • 13. Re: Can I use automator to type text?
    Hiroto Level 5 Level 5 (5,025 points)

    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

  • 14. Re: Can I use automator to type text?
    Pierre L. Level 4 Level 4 (3,860 points)

    Hi Hiroto,

     

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

     

    PL