How do I copy all strings into the clipboard within the script

8 visualizaciones (últimos 30 días)
Lance Randall Gamier
Lance Randall Gamier el 18 de Nov. de 2021
Editada: per isakson el 21 de Nov. de 2021
How do I replicate the consecutive copying of multiples strings into clipboards? The Functions clipboard('copy',variable) and the 'ClipboardHandler' object only stores the last variable to the clipboard when written on a script.
clipboard('copy','TestVariable1')
clipboard('copy','TestVariable2')
clipboard('copy','TestVariable3')
clipboard('copy','TestVariable4')
clipboard('copy','TestVariable5')
Yields the result:
Where only the last variable is recorded. Alternatively, using the copy function on the 'ClipboardHandler' object also does the same
copyobject1 = com.mathworks.page.utils.ClipboardHandler;
copyobject2 = com.mathworks.page.utils.ClipboardHandler;
copyobject3 = com.mathworks.page.utils.ClipboardHandler;
copyobject4 = com.mathworks.page.utils.ClipboardHandler;
copyobject5 = com.mathworks.page.utils.ClipboardHandler;
TestVariable1 = 'TestVariable1'
TestVariable2 = 'TestVariable2'
TestVariable3 = 'TestVariable3'
TestVariable4 = 'TestVariable4'
TestVariable5 = 'TestVariable5'
copyobject1.copy(TestVariable1)
copyobject2.copy(TestVariable2)
copyobject3.copy(TestVariable3)
copyobject4.copy(TestVariable4)
copyobject5.copy(TestVariable5)
But by executing the command in the command window separately, we can get
>> clipboard('copy','TestVariable1')
>> clipboard('copy','TestVariable2')
>> clipboard('copy','TestVariable3')
>> clipboard('copy','TestVariable4')
>> clipboard('copy','TestVariable5')
How do I get a similar result to executing the commands in the command line separately inside a script without resulting to copyng only the last variable to the clipboard?
  4 comentarios
Rik
Rik el 21 de Nov. de 2021
Maybe you can try drawnow after each call to clipboard. Usually that can be used to update the graphics and allow callbacks to run, but maybe it helps here as well.
per isakson
per isakson el 21 de Nov. de 2021
Editada: per isakson el 21 de Nov. de 2021
@Lance Randall Gamier, Thank you for the tip. I had not noticed Clipboard History of Windows 10
How-To Geek: Windows 10 takes copy and paste to another level with a feature called Clipboard history
On my system Clipboard History had to be enabled.
The answer to your question is probably, you cannot, since The MathWorks hasn't yet updated clipboard to take advantage of this new feature.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by