Reputation: 1151
How can I use the content of the clipboard in a function?
When I use Paste[]
it copies it in the current cell of the active notebook. On the other hand, I can easily put an expression to the clipboard using CopyToClipboard[expr]
.
Upvotes: 3
Views: 215
Reputation: 14731
You could try using ClipboardNotebook[]
In[1]:= CopyToClipboard[expression]
In[2]:= an[ToExpression[NotebookGet[ClipboardNotebook[]][[1, 1, 1]]]]
Out[2]= an[expression]
Although you should probably be more careful with it than I have been in the above code. See for example Szabolcs' Mathematica tricks.
Upvotes: 6