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?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

User Image
jcmoxy
2 discussion posts
Hi, I'm trying to create a macro to help me complete an HTML form w the content from the clipboard's history; it should executes in the following sequence: (1) PASTE latest item from Clipboard, (2) TAB, (3) PASTE second latest item from Clipboard and (4) CLEAR clipboard contents. I'm not experienced w/ C# ... The following is my best shot so far, and needs some debugging assistance:

Code

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // your code goes here

            text = BFS.ClipboardFusion.GetHistoryText(0);
            return text;

            BFS.Input.SendKeys("{TAB}");

        string textx;
            textx = BFS.ClipboardFusion.GetHistoryText(1);
            return textx;

//        BFS.Clipboard.Clear();
//        return null;

    }
    
}


Thanks for your time and effort.
May 23, 2018 (modified May 23, 2018)  • #1
Thomas Malloch (BFS)'s profile on WallpaperFusion.com
I put together some code that should work for you, based on the code you provided. It looks like you were really close to getting it working! The only mistake you made was that the "return" statement actually makes the function exit, so not all of your code was run.

Here's what I put together:

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)
    {
        // Tell ClipboardFusion to ignore any changes to the Clipboard.
        // Depending on your settings, pasting text could modify the history
        BFS.ClipboardFusion.PauseClipboardListener();
    
        // Get the first item from the Clipboard History
        text = BFS.ClipboardFusion.GetHistoryText(0);
    
        // Paste the text to the active window
        BFS.Clipboard.PasteText(text);
    
        // Press the "Tab" button
        BFS.Input.SendKeys("{TAB}");
        
        // Get the second item from the Clipboard History
        text = BFS.ClipboardFusion.GetHistoryText(1);
           
        // paste the text to the active window
        BFS.Clipboard.PasteText(text);
            
        // Clear the Clipboard
        BFS.Clipboard.Clear();
    
        // Tell ClipboardFusion to start watching the Clipboard again
        BFS.ClipboardFusion.ResumeClipboardListener();
    
        // Tell ClipboardFusion to ignore the return from this Macro        
        return null;
    }
}


I hope this works for you!
May 24, 2018  • #2
User Image
jcmoxy
2 discussion posts
Thank you so much! I do have a related question though. I expected the clear clipboard statement ( BFS.Clipboard.Clear(); ) to clear the Clipboard Manager of its entries. It did not. Is the Clipboard Manager a separate process not showing the contents of the clipboard, but instead the content that CliboardFusion has worked with?
May 25, 2018 (modified May 25, 2018)  • #3
Thomas Malloch (BFS)'s profile on WallpaperFusion.com
You're exactly right!

The Windows Clipboard has a lot of limitations, one of which being only storing one thing at a time on the Clipboard. ClipboardFusion tries to get around this by watching and storing most of the contents so that you can use it at a later time.

As for your problem, there isn't actually a clear function built into the lists because we felt it was a little too dangerous, but you can remove one item at a time. If you throw it in a loop, you should be able to clear all the items. Here's some example code:

Code

// Warning! This code will clear the Clipboard History if run
while(BFS.ClipboardFusion.GetHistoryItemCount() > 0)
        BFS.ClipboardFusion.RemoveHistoryItem(0);


I hope this helps!
May 29, 2018 (modified May 30, 2018)  • #4
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)