Skip to content

Instantly share code, notes, and snippets.

@leighmcculloch
Created June 17, 2012 11:21

Revisions

  1. @invalid-email-address Anonymous created this gist Jun 17, 2012.
    25 changes: 25 additions & 0 deletions autotype.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Author: Leigh McCulloch
    # License: BSL-1.0 (http://www.opensource.org/licenses/BSL-1.0)
    #
    # This script takes arguments from the command line and autotypes
    # them with tab separators into the last selected application.
    # This can be used from one application to auto-type into another
    # application.
    #
    # Command line usage:
    # osascript autotype.spct [username] [password]
    #
    # Usage in Cocoa application:
    # See http://stackoverflow.com/questions/4909702/run-applescript-from-cocoa-application

    on run argv
    tell application "System Events"
    keystroke tab using (command down)
    delay 0.5
    repeat with arg in argv
    keystroke arg
    keystroke tab
    end repeat
    key code return
    end tell
    end run