Skip navigation

Applescript copy and paste routine

2787 Views 2 Replies Latest reply: Feb 11, 2013 5:55 PM by DanYo23 RSS
DanYo23 Level 1 Level 1 (0 points)
Currently Being Moderated
Feb 7, 2013 11:56 AM

Hey,

I'm a total noob at applescript, but I've been trying to find a way to make code that will copy a line from text edit, paste it into a different application, hit "enter", and then copy the next line in textedit and continue to do so on a loop. Anyone know how to do this? I found a tutorial for a very similar process, but it's for Windows Macro Express. I want the script to do the exact same thing, but hit "enter" after pasting each line.

Anyone know how to do this?

Thanks so much!

 

The tutorial to which I reffered:

http://www.youtube.com/watch?v=ktY35ldDawU

MacBook, Mac OS X (10.7.5)
  • Camelot Level 8 Level 8 (45,670 points)
    Currently Being Moderated
    Feb 7, 2013 6:44 PM (in response to DanYo23)

    Are you really sure that's what you want to do?

    It's possible, but really, really clunky. Having a script (or macro program) emulate user actions is about the poorest approach... granted, sometimes it's the only approach, but that doesn't mean that you shouldn't conisder alternatives.

     

    For example, AppleScript is geared much more towards driving applications directly - i.e. telling them to manipulate data directly - rather than indirectly (e.g. click here, type this, hope for the best). Usually it's better to tell AppleScript to get the selection in any given application, then insert that text at some point somewhere else (rather than using copy/paste).

     

    That said, if that's what you really want:

     

    tell application "TextEdit" to activate

    tell application "System Events"

              tell process "TextEdit"

      keystroke "c" using command down

              end tell

     

    end tell

    delay 0.2

     

    tell application "OtherApp" to activate

    tell application "System Events"

              tell process "OtherApp"

      keystroke "v" using command down

      keystroke return

              end tell

    end tell

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.