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?

User Image
dekiblue1
33 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
33 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
33 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
33 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
User Image
dekiblue1
33 discussion posts
I tried applying the same logic for anoter macro named "Remove Extra White Spaces and Trim" (code bellow) but for some reason it just copies the last item from the normal clipboard.

Code

using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
         Regex regex = new Regex(@" {2,}");
         return regex.Replace(text, " ").Trim();
      }
  }


Anny ideas?
Feb 5, 2024  • #8
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Are you copying the text, running the macro, and then pasting?
Feb 6, 2024  • #9
User Image
dekiblue1
33 discussion posts
Well, I'm using tha macros Keith made to copy directly to a specific pinned slot 0 to 9, but I want to run a macro on it, just like we did few posts before.
Feb 6, 2024  • #10
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
I think you'll just want this code directly in between line 22 and 23:

Code

Regex regex = new Regex(@" {2,}");
return regex.Replace(output, " ").Trim();
Feb 9, 2024  • #11
User Image
dekiblue1
33 discussion posts
You say it should be 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.SetLocalPinnedText(1, BFS.Clipboard.CopyText());
        Regex regex = new Regex(@" {2,}");
        return regex.Replace(output, " ").Trim();
        return null;
    }
}


If I do that and then click on Verify Function I get all kinds of error. Ignoring the
error and applying the macro does not give desired result.

Thank you for your help.
• Attachment [protected]: 2024-02-09 12_15_47-Macro _ ClipboardFusion Pro 6.1.png [7,992 bytes]
Feb 9, 2024 (modified Feb 9, 2024)  • #12
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
You'll need to add the regex namespace at the start of the script, try this:

Code

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

// 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);
        Regex regex = new Regex(@" {2,}");
        return regex.Replace(output, " ").Trim();
        BFS.ClipboardFusion.SetLocalPinnedText(0, output);
        return null;
    }
}
Feb 14, 2024  • #13
User Image
dekiblue1
33 discussion posts
Now the Verify Function gives OK.
However, whatever I select it does not copy it to any Pinned Location... it does not copy it anywhere. I can't see the copied text in the Clipboard Manager.

Here are the last code lines, as per your suggestion, set to store the copied content to Pinned Location #2:

Code

.
    .
    BFS.ClipboardFusion.RunMacro("Remove Extra White Spaces and Trim", text, out string output);
    Regex regex = new Regex(@" {2,}");
    return regex.Replace(output, " ").Trim();
    BFS.ClipboardFusion.SetLocalPinnedText(1, output);
    return null;
    .
    .
Feb 14, 2024  • #14
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Try this:

Code

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

// 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.RunMacro("Remove Extra White Spaces and Trim", output, out string output2);
        BFS.ClipboardFusion.SetLocalPinnedText(0, output2);
        return null;
    }
}
Feb 15, 2024  • #15
User Image
dekiblue1
33 discussion posts
I'll try it but in this macros I only want to trim the white space before and anfter, I don't want to apply the first marco that does the Title Case change.
Feb 15, 2024  • #16
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Ah okay, try this then:

Code

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

// 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("Remove Extra White Spaces and Trim", text, out string output);
        BFS.ClipboardFusion.SetLocalPinnedText(0, output);
        return null;
    }
}
Feb 16, 2024  • #17
User Image
dekiblue1
33 discussion posts
Thank you for your help.

I tried it, but it does not place the copied text to the designated Pinned Slot.
Feb 16, 2024  • #18
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Strange, it seems to work fine here. Are you changing the "0" on line 24 to a 1, 2, 3, for slots 1, 2, 3, etc.?
Feb 20, 2024  • #19
User Image
dekiblue1
33 discussion posts
For now I'm trying only with one of the slots, putting 1 where Pin Slot number goes.

Just weird that it does not copy it to the designated slot.
Feb 20, 2024  • #20
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Could you send me a backup of your settings? You can grab them from the ClipboardFusion Settings > Options > Export Settings
Feb 22, 2024  • #21
User Image
dekiblue1
33 discussion posts
Sure thing.
• Attachment [protected]: ClipboardFusion Backup.db [196,608 bytes]
• Attachment [protected]: ClipboardFusion Backup.reg [364,040 bytes]
Feb 22, 2024  • #22
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
That's really strange, it works fine on my end with your settings as well.

Could you send me a copy of your troubleshooting info? Here are the steps:

  • Open the Settings > Troubleshooting tab
  • Click the "Export Info to File" button
  • Reply with the file attached
Feb 23, 2024  • #23
User Image
dekiblue1
33 discussion posts
Sorry for the wait. Here is the file.
Thank you.
• Attachment [protected]: ClipboardFusionDebugInfo.zip [34,340 bytes]
Feb 29, 2024  • #24
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Thanks for sending that over. Do you have any other apps that might be interfereing here, like the "Power Automate Desktop" app?
Mar 8, 2024  • #25
User Image
dekiblue1
33 discussion posts
Yes, I have PowerAutomate installed. However, even if I quit the PowerAutomate it still does not work. You think I should uninstall the app?

It actualy places whatever I copied last into the pinned slot of the macro in question.
Mar 11, 2024  • #26
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
Just having it closed should be fine. I've tested this on a few different machines with your backup and it seems to work on all of them.

Do you have another machine you could test this out on?
Mar 14, 2024  • #27
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)