How to Use Set-Clipboard Multiple Times in a Script for Clipboard History?

0
13
Asked By CreativeCoder99 On

I'm trying to figure out how to use Set-Clipboard multiple times within a script to keep previous entries in the clipboard history. For instance, if I have 'This is a sentence' in my clipboard, I want to create separate clipboard entries for each word like 'this', 'is', 'a', 'sentence' so that I can easily use Windows + V to select the word I want. Is there a straightforward way to do this that I might be overlooking?

2 Answers

Answered By DataDynamo42 On

If you're using a clipboard manager like Ditto, you can set a time value for loading clip entries, which makes it quicker. I think I set mine to 200 ms, and it worked well for stacking clips. Not sure about the Microsoft clipboard manager, but it might have similar features or even an API. Also, Ditto has some nice extras like paste macros and pinned clips.

ClipboardNinja77 -

Oh, that sounds interesting! I might look into that.

Answered By ClipboardNinja77 On

You should definitely enable Windows+V, then loop through each word in your array and apply Set-Clipboard for each one. Just a quick script I tested goes like this:

'a','b','c' | ForEach-Object {Write-Host "Putting $_ in clipboard"; $_ | Set-Clipboard; Start-Sleep -Seconds 2}

This way, you give yourself a little time between each entry. What's your specific situation for needing this?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.