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
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.
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?

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