How to set certain text to the clipboard through Applescript?

Discussion in 'Mac Programming' started by rebello95, Nov 8, 2011.

  1. rebello95 macrumors member

    Joined:
    Jun 15, 2011
    Location:
    USA
    #1
    I've tried using

    set the clipboard to "xxx"

    but that doesn't work. Ideas? Thanks!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Works for me: OS 10.6.8.

    Typed it into AppleScript Editor, told it to Run.
    Confirmed it worked using 'pbpaste' command in Terminal.


    What is your OS version?

    How do you know it doesn't work? I.e. describe the steps you took and what you observed that lead you to conclude it doesn't work.
     
  3. rebello95 thread starter macrumors member

    Joined:
    Jun 15, 2011
    Location:
    USA
    #3
    I'm running on 10.7.2 right now. I ran the application then tried using command + v to test it.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    It worked for me. Pasted it into TextEdit and into Terminal.


    Try opening a new window in AppleScript Editor.
    Enter this script:
    Code:
    get the clipboard
    
    Click Run.
    Post the result.
    If there's no result, say "There's no result".

    Select the entire text of the script.
    Choose Copy from Edit menu.
    Click Run.
    Does the Result show "get the clipboard"?


    Also, you need to explain exactly what "I ran the application" means.

    I'm not "running an application" when I do these tests. I'm simply using AppleScript Editor, and telling it to Run a script I've typed in. It's not an application yet. It's just a piece of script.

    If you're using AppleScript Editor, you need to identify that. If you're using something else, identify that. "I ran the application" is too vague. Be specific.
     
  5. rebello95 thread starter macrumors member

    Joined:
    Jun 15, 2011
    Location:
    USA
    #5
    When I try that, it crashes. I have 4GB of RAM in my MacBook so that's not the problem...
     
  6. Partron22 macrumors 68000

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #6
    Have you done this?
    Well behaved Apps don't usually need the tell block.
    Less well behaved ones may.
    Try this:
    Code:
    tell application "Minecraft"
    	set the clipboard to "Funky Cold Medina"
    end tell
     
  7. rebello95 thread starter macrumors member

    Joined:
    Jun 15, 2011
    Location:
    USA

Share This Page