Clipboard Fusion 剪贴板软件介绍及宏命令分享

Clipboard Fusion 也是一个支持编程的剪贴板增强软件,支持触发器、同步和宏功能。

支持中文,支持跨平台(Windows、Android、iOS、MacOS、Web),其免费版本不支持同步。

它的宏支持VB.net和C#代码,与CopyQ的命令相比,更容易调试且更强大。
你可以通过设置热键、触发器、菜单等方式来调用宏。
可以通过添加、编辑、导入、导出、下载、同步、分享到社区等方式来使用宏。

所以,不论是完全不懂编程的小白,还是懂得编程的高级用户,都可以很好的满足自己的需求。

Clipboard Fusion 的代码编辑器具备代码提示、调试、测试的功能。还可以调用 net frame 框架,实现winform级别的编程能力。

你可以点此查看社区分享的宏代码

由于社区主要是英文,所以下面是我觉得比较有用的中文代码,会不定期分享给大家。

一键将复制的Markdown粘贴为HTML渲染后的文字

你需要指定 pandoc 的路径

using System;
using System.IO;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;

public static class ClipboardFusionHelper
{
	[STAThread] 
    public static string ProcessText(string text)
    {
        if (string.IsNullOrWhiteSpace(text))
            return text;

        string pandocPath = @"D:\Tools\开发设计\pandoc\pandoc.exe";
        if (!File.Exists(pandocPath))
        {
            BFS.Dialog.ShowMessageError("Pandoc 未找到,路径:" + pandocPath);
            return text;
        }

        string tempMd = Path.GetTempFileName() + ".md";
        string rtfOutput = "";

        try
        {
            // 写入临时文件:UTF-8 with BOM,确保正确处理中文和换行
            File.WriteAllText(tempMd, text, new UTF8Encoding(true));

            // 启用 hard_line_breaks 保留单个换行
            string args = $"\"{tempMd}\" -f markdown+hard_line_breaks -t html --standalone --wrap=none";
			//string args =$"-f markdown -t rtf \"{tempMd}\"";
            var psi = new ProcessStartInfo
            {
                FileName = pandocPath,
                Arguments = args,
                UseShellExecute = false,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                CreateNoWindow = true,
                StandardOutputEncoding = Encoding.UTF8,
                StandardErrorEncoding = Encoding.UTF8
            };

            using (var process = Process.Start(psi))
            {
                rtfOutput = process.StandardOutput.ReadToEnd();
                string error = process.StandardError.ReadToEnd();
                process.WaitForExit();

                if (process.ExitCode != 0)
                {
                    BFS.Dialog.ShowMessageError("Pandoc 转换失败:\n" + error);
                    return text;
                }
            }

			BFS.Clipboard.SetHTML(rtfOutput);
			BFS.Clipboard.Paste();
            // 成功提示(可选,如需静默可删除)
			//BFS.Dialog.ShowTrayMessage("已转换为HTML渲染格式,切换到支持的应用程序粘贴即可!");

			return null;
        }
        catch (Exception ex)
        {
            BFS.Dialog.ShowMessageError("Error:\n" + ex.Message + "\n" + ex.StackTrace);
			return text;
        }
        finally
        {
            if (File.Exists(tempMd))
                File.Delete(tempMd);
			
        }
		
    }
}

1 个赞