How do I copy all strings into the clipboard within the script
8 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Rik
2021 年 11 月 21 日
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
2021 年 11 月 21 日
編集済み: per isakson
2021 年 11 月 21 日
@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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!