Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
DS1508
37 discussion posts
Hello,
I had some problems with all those hotkeys for my macros. So I created a macro that shows a popup menu with a defined list of macros. Just download the attached "ShowCustomFunctionList.cfmacro" and import it. File Attachment see post #5 below.

---

After import edit the macro and fill it with your macro-names. Hints are in the code :)

Have fun.
DS
PS: Maybe this could be added to the macro downloads, or pinned thread?
Oct 3, 2016 (modified Oct 6, 2016)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Awesome! We'll test this out here and add it to the repository. Thanks for sharing that :)
Oct 3, 2016  • #2
User Image
DS1508
37 discussion posts
I don't know why there's no popup for the macros. I think they're the best feature of CF. ;)
Oct 3, 2016  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
We do actually have an open feature request for that as well, so I've added your vote to it :)

Thanks!
Oct 5, 2016  • #4
User Image
DS1508
37 discussion posts
OK, changed the macro.
Here's the new version.
- added hotkeys
- checks for image or text, and disables/enables popup menu entries
- added description

Code

using System;
using System.Drawing;
using System.Windows.Forms;

/****************************************************************************************************************
**This Macro will show a pop-up dialog with a list of Macros that you can run.
**Just replace the Macro names in the "MenuEntries" variable at the top of the script, with the names of
**your Macros.
**eg:{{ "PaleGreen", "Black", "Copy and Append", "Copy and &Append selected text", "cb-content" }},
**- "PaleGreen" is the background color
**- "Black" is the foreground-(text) color
**- "Copy and Append" is the macro name as it appears in your macro list
**- "Copy and &Append selected text" is the text you will see in the popup, here the "A" is set as hotkey
**- "cb-content" can be "image", "text", "all". It defines if the entry is clickable or not. If the macro needs
**an image in the clipboard, the entry is disabled if there's only text on the cb.
**
**Color names can be found here:
**http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/colors/ColorTable.htm
**
**Add an ampersand (&) at the fourth parameter to get a hotkey for the entry.
**  eg:{{ "Pink", "Maroon", "--- Cancel ---", "--- &Cancel ---" }},
**{{ "PaleGreen", "Black", "Copy and Append", "Copy and &Append selected text" }},
**
**If you want an entry to cancel the action please use:
**{{ "Background color", "Foreground color", "--- Cancel ---", "--- &Cancel ---" }},
**
** You can also click outside the popup or press ESC to cancel/close.
**
*****************************************************************************************************************/

public static class ClipboardFusionHelper
{
public static string ProcessText(string text)
{

// These are all of the macros from the "Macros" list.
// See description above.
string[, ,] MenuEntries = 
{
//{{ "Background-Color", "Foreground-Color", "Macro-Name", "Menu entry text", "image text all" }}
{{ "Pink", "Maroon", "--- Cancel ---", "--- Cancel ---", "all" }},
{{ "Khaki", "Black", "Remove Extra White Spaces and Trim", "&1 Remove Extra White Spaces and Trim", "text" }},
{{ "Khaki", "Black", "Replace special chars with spaces, Trim", "&2 Replace special chars with spaces then Trim", "text" }},
{{ "BurlyWood", "Black", "Auto-Type Clipboard Text", "Auto-&Type Clipboard Text", "text" }},
{{ "BurlyWood", "Black", "Show History Drop-Down List, Modify", "Show &History Drop-Down List, and modify value", "text" }},
{{ "PaleGreen", "Black", "Copy and Append", "Copy and &Append selected text", "text" }},
{{ "Aquamarine", "Black", "Decode Base64-Encoded Text (UTF-8)", "Decode Base64-Encoded Text (UTF-8)", "text" }},
{{ "Aquamarine", "Black", "Decode URL-Encoded Text", "Decode URL-Encoded Text", "text" }},
{{ "Aquamarine", "Black", "Encode Text (UTF-8) using Base64-Encoding", "Encode Text (UTF-8) using Base64-Encoding", "text" }},
{{ "Aquamarine", "Black", "Encode Text using URL-Encoding", "Encode Text using URL-Encoding", "text" }},
{{ "Darkseagreen", "Black", "Search For Copied Text using Google.de", "Search for text in clipboard using &Google.de", "text" }},
{{ "Darkseagreen", "Black", "URL Grabber", "URL Grabber", "text" }},
{{ "White", "Black", "Save Copied Image to Disk", "Save &image in clipboard to disk", "image" }},
{{ "Pink", "Maroon", "--- Cancel ---", "--- Cancel ---", "all" }}
};

// Create a new ContextMenuStrip to show the items
using(ContextMenuStrip menu = new ContextMenuStrip())
{
// Don't show the padding on the left of the menu
menu.ShowCheckMargin = false;
menu.ShowImageMargin = false;

string cbContent = "";
if ( BFS.Clipboard.HasText() ) cbContent = "text";
if ( Clipboard.ContainsImage() ) cbContent = "image";

// Add items to the menu, and use custom function when the user clicks on the items
for ( int i = 0; i < MenuEntries.GetLength(0); i++ ) {
ToolStripMenuItem item = new ToolStripMenuItem(MenuEntries[i, 0, 3]);
item.Click += MenuItem_Click;
item.BackColor = Color.FromName( MenuEntries[i, 0, 0]);
item.ForeColor = Color.FromName( MenuEntries[i, 0, 1]);
item.Tag = MenuEntries[i, 0, 2];
if ( (MenuEntries[i, 0, 4] == cbContent) || (MenuEntries[i, 0, 4] == "all") || (cbContent == "") )
item.Enabled = true;
else
item.Enabled = false;
menu.Items.Add(item);
}

// Finally show the popup menu
menu.Show(new Point(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY()), ToolStripDropDownDirection.AboveRight);

// Set focus to the menu
menu.BringToFront();
menu.Focus();
BFS.Window.Focus(menu.Handle);
BFS.Window.SetAlwaysOnTop(menu.Handle, true);

// Wait for the menu to close
while(menu.Visible)
{
Application.DoEvents();
}
}
return null;
}

/****************************************************************************************************************
**This function will get the text of the clicked item and try to run it as a ClipboardFusion Macro.
*****************************************************************************************************************/
private static void MenuItem_Click(object sender, EventArgs e)
{
ToolStripItem item = sender as ToolStripItem;
if (item == null) return;
// Get the macro name
string macroName = item.Tag as String;
if ( (macroName == "--- Cancel ---") || (macroName == "") ) return;

string text = BFS.Clipboard.GetText();
if (text == null) text = "";
// Return values
string rText = "";
string rError = "";
// Run the macro
BFS.ClipboardFusion.RunMacro(macroName, text, out rText, out rError);
// Any errors?
if ( rError != "" ) {
BFS.Dialog.ShowMessageError("An error has occurred:\n"+rError);
} else {
BFS.Clipboard.SetText(rText);
}
}
}
• Attachment: ShowCustomFunctionList.cfmacro [32,552 bytes]
Oct 5, 2016 (modified Oct 6, 2016)  • #5
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Updated in the repository, thanks!
Oct 6, 2016  • #6
User Image
dh_fusion
3 discussion posts
Just out of curiosity.. Where are macros stored? Are they only stored on the ClipboardFusion sync servers? I was searching everywhere on my computer for a local repo to no avail. I don't even have an account linked to clipboard fusion so if it is just the sync servers it must be on there with some random GUID linked to my install?

Anyway, I was hoping to augment this macro to load all of my installed macros or maybe based on a config (or admin menu if possible). I am missing a starting point though: The ability to enumerate installed macros. I was poking around in the build in functions and didn't find anything like this. Worst case scenario, I suppose, I could connect to a local middleware that scrapes macro names from my account online if I have to link it ;)

Off topic: Thank you soooooo much for all of the new features in the new beta! This can almost assuredly become my new full time clipboard manager (with a few improvements that might be on the way I guess). If it all pans out in the release version of 5.x i'll definitely buy a few more copies.
Dec 15, 2016  • #7
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Glad to hear you like the new betas!

The macros are stored in the registry: HKEY_CURRENT_USER\SOFTWARE\Binary Fortress Software\ClipboardFusion\Macros
Dec 20, 2016  • #8
User Image
dh_fusion
3 discussion posts
Quote:
The macros are stored in the registry: HKEY_CURRENT_USER\SOFTWARE\Binary Fortress Software\ClipboardFusion\Macros


Huh... interesting. I would never have thought to look there.

Well cool. I'm pretty sure that is accessible to me so I'll see what I can come up with.

Thanks for the info!
Dec 20, 2016  • #9
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)