Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1393 > unrolled thread
| Started by | mmausr <opngid@gmail.com> |
|---|---|
| First post | 2011-04-01 07:34 +0000 |
| Last post | 2011-04-02 07:54 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
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
| From | mmausr <opngid@gmail.com> |
|---|---|
| Date | 2011-04-01 07:34 +0000 |
| Subject | Easy way to read clipboard? |
| Message-ID | <in3v6n$i0i$1@smc.vnet.net> |
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?
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2011-04-02 07:53 +0000 |
| Message-ID | <in6kks$2kg$1@smc.vnet.net> |
| In reply to | #1393 |
On 01/04/2011 08:34, mmausr 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? > > > You can obtain the clipboard in the form of a notebook expression: NotebookGet[ClipboardNotebook[]] This is a bit messy however, because in general, the contents of the clipboard under Mathematica, may contain several cells, including text cells, and formatting information. If you knew that the clipboard should only contain a certain type of thing - say a number, or an expression, you could write code to extract it from the notebook expression, but to make it robust, you would have to decide what to do with all the other things that might be in the clipboard - such as: foo[ David Bailey http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | Jon McLoone <jonm@wolfram.co.uk> |
|---|---|
| Date | 2011-04-02 07:54 +0000 |
| Message-ID | <in6kn6$2le$1@smc.vnet.net> |
| In reply to | #1393 |
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]]
[toc] | [prev] | [next] | [standalone]
| From | David Reiss <dbreiss@gmail.com> |
|---|---|
| Date | 2011-04-02 07:54 +0000 |
| Message-ID | <in6knr$2lj$1@smc.vnet.net> |
| In reply to | #1393 |
NotebookGet@ClipboardNotebook[] or any other notebook manipulation commands on ClipboardNotebook[] --David On Apr 1, 3: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?
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web