From: magma on
On Jun 9, 1:18 pm, David Bailey <d...(a)removedbailey.co.uk> wrote:
> On 07/06/10 13:06, magma wrote:
>
>
>
> > The clipboard is meant to be used for things that have been selected
> > (manually or programmatically) from some place (in Mathematica: a noteb=
ook).
> > Any other unconventional use would not adhere to the standard GUI
> > conventions (tautologically) and probably reflects a not very well
> > thought out interface.
>
> I disagree with this philosophy, in that when you build an interface, a
> "Copy" button copies whatever it is that the program is logically
> manipulating at that point - which may not be what is on the screen.
>
> There is some functionality in Mathematica to handle this, but you
> probably need to experiment a bit to get the effect just right. Here is
> an example to start Istvan off:
>
> In[4]:= fred = {a, b, c}
>
> Out[4]= {a, b, c}
>
> In[6]:= NotebookWrite[ClipboardNotebook[], fred]
>
> Global`a
>
> Global`b
>
> Global`c
>
> David Bailey
>
> http://www.dbaileyconsultancy.co.uk

Well then, there is your solution Istvan.
ClipboardNotebook[] is an undocumented way to access the clipboard.
For some reason, regular users are not supposed to know of its
existence.
However note that you get the context of the variables in your
expression too.
I doubt this is what you really like, if you mean to paste into a
different program


From: ADL on
It may be also interesting to note that, if you wish to copy in the
clipboard a string without quotation marks, you may use the following:

CopyToClipboard[expr_] :=
Module[{nb},
nb = CreateDocument[Null, Visible -> False, WindowSelected ->
True];
NotebookWrite[nb, Cell[OutputFormData @ expr], All];
FrontEndExecute[FrontEndToken[nb, "Copy"]];
NotebookClose @ nb
];

It works on version Win 7.0.1

ADL