Re: How to copy to clipboard
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