MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Easy way to read clipboard?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117881] Re: Easy way to read clipboard?
  • From: Jon McLoone <jonm at wolfram.co.uk>
  • Date: Sat, 2 Apr 2011 02:44:30 -0500 (EST)
  • References: <in3v6n$i0i$1@smc.vnet.net>

On Apr 1, 8:34 am, mmausr <opn... at gmail.com> wrote:
> The Paste[] command will paste the current contents of the clipboard
> into a cell.  In theory, one can then access the contents of a cell by
> executing front-end commands in the kernel, but I'd prefer something
> more direct.
>
> Say that I want to set the variable Foo to the current contents of the
> Clipboard, which holds the number 100.  I'd like to be able to execute
> something like Foo = ReadClipboard[] and have Foo set to the integer
> value 100.
>
> Any suggestions?

NotebookGet[ClipboardNotebook[]]

is the basis for what you want. It will return a Notebook expression,
that may contain anything, so needs to be analyzed.

In the simplest case, where you assume that the clipboard contains
syntactically correct text, eg "100" then this will work...

foo = First[Cases[NotebookGet[ClipboardNotebook[]], Cell[text_,
___] :> ToExpression[text], Infinity]]


  • Prev by Date: Re: question about ODE
  • Next by Date: Re: Mathematica 8.01 and the CDF plug-in
  • Previous by thread: Re: Easy way to read clipboard?
  • Next by thread: Re: Easy way to read clipboard?