Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1425
| From | Jon McLoone <jonm@wolfram.co.uk> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Easy way to read clipboard? |
| Date | 2011-04-02 07:54 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <in6kn6$2le$1@smc.vnet.net> (permalink) |
| References | <in3v6n$i0i$1@smc.vnet.net> |
On Apr 1, 8:34 am, mmausr <opn...@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]]
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Easy way to read clipboard? mmausr <opngid@gmail.com> - 2011-04-01 07:34 +0000 Re: Easy way to read clipboard? David Bailey <dave@removedbailey.co.uk> - 2011-04-02 07:53 +0000 Re: Easy way to read clipboard? Jon McLoone <jonm@wolfram.co.uk> - 2011-04-02 07:54 +0000 Re: Easy way to read clipboard? David Reiss <dbreiss@gmail.com> - 2011-04-02 07:54 +0000
csiph-web