Processing Ajax...

Close Dialog


Close Dialog

Close Dialog

c# find words in clipboard and output

User Image
Patrick Cunningham23565
2 discussion posts
I'm trying to make a macro so that each of these words that would be located in my clipboard would be put into a list with spaces and commas, then output back to the clipboard. I'm not sure I need the first and last lines. I cant seem to get it to run. What am I missing?

string Text = Clipboard.GetText();
List<string> words = new List<string> { "blue", "green", "chair" };
Join IEnumerable<string> foundWords = words.Where(i => Text.Contains(i));
string result = string.Join(", ", foundWords);

if the clipboard only contained one or all three thats what the clipboard would be replaced with. I would be adding a ton of words to search and would like them output in the order they are searched for, without duplicates.
Dec 13, 2021  • #1
Thomas Malloch (BFS)'s profile on
I've put together a Macro that should work for you using your example code above :). When running a macro with a hotkey, the text parameter is set to the contents of the current Clipboard, so there's no need to grab the text from the Clipboard again. It's also the same with the returned value. The Clipboard gets set to that returned value when the Macro is finished running, unless it's null. You might have also forgot a "using" statement to get those Linq functions to work.

I hope this helps! Here's how to get the Macro into ClipboardFusion:

  • Download the file attached to this email
  • Open the ClipboardFusion Settings window
  • On the "Macros" tab, click the "Import" button
  • Select the file you downloaded in the first step
  • In the window that pops up, you can review the code and assign the Macro a HotKey
  • Click OK to close the Macro Edit window, then OK again to save and apply your changes

• Attachment: Return List of Words Found in Text.cfmacro [7,672 bytes]
Dec 16, 2021 (modified Dec 16, 2021)  • #2
User Image
Patrick Cunningham23565
2 discussion posts
Sorry I never got a notification that this was responded to, thanks a ton for helping out!
Jan 25, 2022  • #3
Was this helpful?  Login to Vote(1)  Login to Vote(-)