Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Copy Selected Text to Local Pinned Items (clears existing Pinned Items)

Description
This script will clear the Local Pinned Items list and add each line from the selected text to the Local Pinned Items.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Jul 3, 2019
Date Last Modified
Jul 26, 2019

Macro Code

using System;
using System.Collections.Generic;

// The 'text' parameter will contain the text from the:
//   - Current Clipboard when run by HotKey
//   - History Item when run from the History Menu
// The returned string will be:
//   - Placed directly on the Clipboard
//   - Ignored by ClipboardFusion if it is 'null'
public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
        // Copy the selected text from the focused window
		text = BFS.Clipboard.CopyText();
		
		// Split it into separate lines
		string[] stringSeparators = new string[]{"\r\n"};
		string[] lines = text.Split(stringSeparators, StringSplitOptions.None);
		
        // Clear the local pinned items
        while (BFS.ClipboardFusion.GetLocalPinnedItemCount() > 0)
        {
            BFS.ClipboardFusion.RemoveLocalPinnedItem(0);
        }
        
        // Add the copied lines to the local pinned items
		foreach (string line in lines)
		{
            BFS.ClipboardFusion.AddLocalPinnedText(line);
		}

        // Exit and leave the clipboard alone
		return null;
	}
}