• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to copy to clipboard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to copy to clipboard


  • Subject: Re: How to copy to clipboard
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 27 Apr 2001 08:39:06 -0700

On 4/27/01 8:22 AM, "Roberto Targa" <email@hidden> wrote:

> Hi scripters,
> I need to copy the computer name to the clipboard and use following script:
>
> set MyName to ""
> tell application "File Sharing"
> set MyName to computer name
> quit
> end tell
> copy myName to the clipboard
>
> The variable has the exact computer name but I get a syntax error such as :
> "Can't set "Macintosh HD" to "
>
You can't use 'copy' that way. 'the clipboard' is a scripting addition, a
command (meaning 'get the clipboard) not an object as you'd think. There is
a separate scripting addition command 'set the clipboard to' which is what
you have to use:

tell application "File Sharing"
set MyName to computer name
quit
end tell
set the clipboard to MyName


The odd thing is that it works this way! You're supposed to have to put it
in a tell block to the application and activate it first:

tell application "File Sharing"
activate
set MyName to computer name
set the clipboard to MyName
quit
end tell
the clipboard


Even then, you can get the clipboard after leaving the tell block, and it's
still what you put there, as you'd hope.

Could someone remind me when/why the system clipboard cooperates in this
fashion, and/or the Standard Additions' (i.e. Jon's Commands') various
clipboard commands specify an application's clipboard within a tell block?
When doesn't it work outside a tell block?

--
Paul Berkowitz


References: 
 >How to copy to clipboard (From: Roberto Targa <email@hidden>)

  • Prev by Date: Re: How to copy to clipboard
  • Next by Date: RE: How to copy to clipboard
  • Previous by thread: Re: How to copy to clipboard
  • Next by thread: RE: How to copy to clipboard
  • Index(es):
    • Date
    • Thread