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 Text/Image/Files to Local Pinned Slot 01

Description
This macro will copy the selected text/image/files and put it in Local Pinned Slot 01. For images, depending on where you're copying them from, you may need to copy the image manually first, then run this Macro. Duplicate this macro and change the slot number on line 17 to use it for other Local Pinned slots.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Aug 13, 2019
Date Last Modified
Aug 13, 2019

Macro Code

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;

// 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)
	{
		// Set the slot number here (it's 0 based, so 0 is slot 1, 1 is slot 2, etc)
		int slotNumber = 0;
		
		// Send the copy command
		BFS.Clipboard.Copy();
		
		// Put the item in the local pinned slot
		if (BFS.Clipboard.HasText()) // Text
        {
            BFS.ClipboardFusion.SetLocalPinnedFileList(slotNumber, null);
            BFS.ClipboardFusion.SetLocalPinnedImage(slotNumber, null);
            BFS.ClipboardFusion.SetLocalPinnedText(slotNumber, BFS.Clipboard.GetText());
        }
        else if (BFS.Clipboard.HasImage()) // Image
        {
            BFS.ClipboardFusion.SetLocalPinnedFileList(slotNumber, null);
            BFS.ClipboardFusion.SetLocalPinnedImage(slotNumber, (Bitmap)Clipboard.GetImage());
            BFS.ClipboardFusion.SetLocalPinnedText(slotNumber, "Image");
        }
        else if (Clipboard.ContainsFileDropList()) // Files
        {
            string[] files = new string[Clipboard.GetFileDropList().Count];
            Clipboard.GetFileDropList().CopyTo(files, 0);
            string itemLabel = string.Join("\r\n", files);
        
            BFS.ClipboardFusion.SetLocalPinnedFileList(slotNumber, files);
            BFS.ClipboardFusion.SetLocalPinnedImage(slotNumber, null);
            BFS.ClipboardFusion.SetLocalPinnedText(slotNumber, itemLabel);
        }
		
		return null;
	}
}