Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

Applying a macro twice?

User Image
dekiblue1
23 discussion posts
Few years ago Keith gave me (us) some macros:
https://www.clipboardfusion.com/Discussions/View/copypaste-tofrom-specific-memory/?ID=7d7071b2-b9bd-4462-a312-7d48e2356b42
You basicaly assign a number of shortcuts so that you copy/paste directy to memory slots. Like, say you set CTRL+SHIFT+1 to copy to slot #1 and with CTRL+ALT+1 you paste from slot #1. It is a marvelous solution for me.

It would be nice if I could apply some macro at the same time when I copy or paste from a slot, specialy the macro Convert Text to Title Case (Smart).

Can it be done?
Oct 3, 2023  • #1
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
You can add the "BFS.ClipboardFusion.RunMacro" line to your script to run it twice
Oct 5, 2023  • #2
User Image
dekiblue1
23 discussion posts
Quote:
You can add the "BFS.ClipboardFusion.RunMacro" line to your script to run it twice


Sorry, not a programmer. If this is my script, how do I make it run the macro Convert Text to Title Case (Smart)?
I assume I should have the macro in question downloaded first.

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)
    {
        int localPinnedItemCount = BFS.ClipboardFusion.GetLocalPinnedItemCount();
        if (localPinnedItemCount < 10)
        {
            for (int i = localPinnedItemCount; i < 10; i++)
            {
                BFS.ClipboardFusion.AddLocalPinnedText("--placeholder--");
            }
        }    
        BFS.ClipboardFusion.SetLocalPinnedText(0, BFS.Clipboard.CopyText());
        return null;
    }
}
Oct 5, 2023  • #3
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
The format for the line will look like this: BFS.ClipboardFusion.RunMacro("Convert Text to Title Case (Smart)", text, out string output);

and you'll want to add it right before it pins into ClipboardFusion on line 22, so it should look like this:

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)
    {
        int localPinnedItemCount = BFS.ClipboardFusion.GetLocalPinnedItemCount();
        if (localPinnedItemCount < 10)
        {
            for (int i = localPinnedItemCount; i < 10; i++)
            {
                BFS.ClipboardFusion.AddLocalPinnedText("--placeholder--");
            }
        }
        BFS.ClipboardFusion.RunMacro("Convert Text to Title Case (Smart)", text, out string output);
        BFS.ClipboardFusion.SetLocalPinnedText(0, output);
        return null;
    }
}
Oct 5, 2023  • #4
User Image
dekiblue1
23 discussion posts
Quote:
The format for the line will look like this: BFS.ClipboardFusion.RunMacro("Convert Text to Title Case (Smart)", text, out string output);

and you'll want to add it right before it pins into ClipboardFusion on line 22, so it should look like this:

Code

using System;
using System.Collections.Generic;
....
        }
        BFS.ClipboardFusion.RunMacro("Convert Text to Title Case (Smart)", text, out string output);
        BFS.ClipboardFusion.SetLocalPinnedText(0, output);
        return null;
    }
}


I did as you suggested but it does not Run the Macro in question... it makes no changes to the text I pasted.
Oct 5, 2023 (modified Oct 5, 2023)  • #5
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Strange, it seems to work here. Try importing the script directly from the attachment below.
Oct 6, 2023  • #6
User Image
dekiblue1
23 discussion posts
I figured it out.

The line after running the macro in your script is:

Code

BFS.ClipboardFusion.SetLocalPinnedText(0, output);


and in my script is:

Code

BFS.ClipboardFusion.SetLocalPinnedText(0, BFS.Clipboard.CopyText());


Now it works.

Thanks! :)
Oct 6, 2023  • #7
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)