Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Show History Drop-Down List, Modify and Paste Selected Item

Description
This Macro will show a drop-down list that contains the items in the ClipboardFusion History. After choosing an item from the list and clicking OK, the item is manipulated (in this example, it's wrapped in tags for pasting URLs into HTML code), and then pasted into the last active textbox.
Language
C#.net
Minimum Version
Created By
Jon Tackabury (BFS)
Contributors
-
Date Created
Dec 19, 2014
Date Last Modified
Dec 19, 2014

Macro Code

using System;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
		// get the number of items in the history
		int count = BFS.ClipboardFusion.GetHistoryItemCount();
		if (count <= 0)
		{
			// show an error and return if there are no items
			BFS.Dialog.ShowMessageError("Sorry, there are no items currently in your History.");
			return "";
		}
		
		// build the history selection dialog by getting each item in the history
		List<string> items = new List<string>();
		for (int a=0; a<count; a++)
			items.Add(BFS.ClipboardFusion.GetHistoryText(a));
			
		// show the history selection dialog
		text = BFS.Dialog.GetUserInputList("Select a History Item", items.ToArray());
		
		// if the user cancels, return without doing anything
		if (text.Length == 0)
			return "";
		
		// generate the return text using the value the user selected (in this case it's an HTML link)
		text = "<a href=\"" + text + "\" target=\"_blank\"><b>XXXX</b></a>";
		
		// paste the generated text into the currently active window
		BFS.Clipboard.PasteText(text);
		return text;
	}
}