ClipboardFushion预制宏汇总

自动打字(剪贴板文字)

Auto-Type Clipboard Text 注意:只是适用于英文打字,中文打字不适用(所以不建议自己用)

    This macro will type the clipboard text into the currently focused window, instead of pasting it.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Text;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        BFS.General.ThreadWait(2000);
        StringBuilder sendKeyString = new StringBuilder();
        bool isShiftDown = false;
        foreach(char c in text)
        {
            //smart shift syntax building for letters
            if(char.IsLetter(c) || c == ' ')
            {
                if(char.IsUpper(c) && isShiftDown)
                {
                    sendKeyString.Append(c);
                    continue;
                }
                
                if(char.IsUpper(c) && !isShiftDown)
                {
                    isShiftDown = true;
                    sendKeyString.Append("+(").Append(c);
                    continue;
                }
                
                if(char.IsLower(c) && isShiftDown)
                {
                    isShiftDown = false;
                    sendKeyString.Append(')').Append(char.ToUpperInvariant(c));
                    continue;
                }
                
                if(char.IsLower(c) && !isShiftDown)
                {
                    sendKeyString.Append(char.ToUpperInvariant(c));
                    continue;
                }
            }
            
            if(char.IsDigit(c))
            {
                if(isShiftDown)
                {
                    isShiftDown = false;
                    sendKeyString.Append(')').Append(c);
                    continue;
                }
                
                sendKeyString.Append(c);
                continue;
            }
            
            //turn off smart shift here
            if(isShiftDown)
            {
                isShiftDown = false;
                sendKeyString.Append(')');
            }
            
            //this part will only work with en-us keyboards
            switch(c)
            {
                case '~':
                    sendKeyString.Append("+(`)");
                    break;
                case '!':
                    sendKeyString.Append("+(1)");
                    break;
                case '@':
                    sendKeyString.Append("+(2)");
                    break;
                case '#':
                    sendKeyString.Append("+(3)");
                    break;
                case '$':
                    sendKeyString.Append("+(4)");
                    break;
                case '%':
                    sendKeyString.Append("+(5)");
                    break;
                case '^':
                    sendKeyString.Append("+(6)");
                    break;
                case '&':
                    sendKeyString.Append("+(7)");
                    break;
                case '*':
                    sendKeyString.Append("+(8)");
                    break;
                case '(':
                    sendKeyString.Append("+(9)");
                    break;
                case ')':
                    sendKeyString.Append("+(0)");
                    break;
                case '_':
                    sendKeyString.Append("+(-)");
                    break;
                case '+':
                    sendKeyString.Append("+(=)");
                    break;
                case '{':
                    sendKeyString.Append("+([)");
                    break;
                case '}':
                    sendKeyString.Append("+(])");
                    break;
                case '|':
                    sendKeyString.Append("+(\\)");
                    break;
                case ':':
                    sendKeyString.Append("+(;)");
                    break;
                case '"':
                    sendKeyString.Append("+(')");
                    break;
                case '<':
                    sendKeyString.Append("+(,)");
                    break;
                case '>':
                    sendKeyString.Append("+(.)");
                    break;
                case '?':
                    sendKeyString.Append("+(/)");
                    break;              
                default:
                    sendKeyString.Append(c);
                    break;
            }
        }
        
        BFS.Input.SendKeys(sendKeyString.ToString());
        return text;
    }
}

经典风格历史菜单

Classic Style History Menu 就是一个老版本的剪贴板历史记录菜单,不推荐用这个宏

    This macro recreates the classic style of the history menu from ClipboardFusion 4.x.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Collections.Specialized;
using System.Drawing;
using System.Windows.Forms;

// 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)
    {
        //create a new ContextMenuStrip to show the items
        using(ContextMenuStrip menu = new ContextMenuStrip())
        {
            //dont show the padding on the left of the menu
            menu.ShowCheckMargin = false;
            menu.ShowImageMargin = false;
            
            //set the font so it isn't huge
            menu.Font = new Font(menu.Font.FontFamily, 8, FontStyle.Regular);
            
            //loop through the first 25 history items
            for(int i = 0; (i < BFS.ClipboardFusion.GetHistoryItemCount()) && (i < 25); i++)
            {
                //get the history item data
                text = BFS.ClipboardFusion.GetHistoryText(i);
                Bitmap image = BFS.ClipboardFusion.GetHistoryImage(i);
                string[] fileList = BFS.ClipboardFusion.GetHistoryFileList(i);
                
                //strip the newline characters out of the text for the title, and limit it to 50 characters
                string title = string.IsNullOrEmpty(text) ? "[Empty]" : text;
                title = title.Replace(Environment.NewLine, "\n").Replace("\r", "\n").Replace("\n", "");
                if(title.Length > 50)
                
                    title = title.Substring(0, 50);
                
                //make the context menu item
                ToolStripMenuItem item = new ToolStripMenuItem(title);
                
                //if the item contains an image, set the background image to the item
                if(image != null)
                {
                    item.BackgroundImage = image;
                    item.BackgroundImageLayout = ImageLayout.Stretch;
                }
                
                //make the ClipboardData object
                ClipboardData data = new ClipboardData(text, image, fileList);  
                
                //set the click event, set the ClipboardData to the tag, and add the item to the menu
                item.Click += ItemClick;
                item.Tag = data;
                menu.Items.Add(item);
            }
            
            //add an item that you can click to close the menu
            menu.Items.Add("Close");
            menu.Items[menu.Items.Count - 1].ForeColor = Color.Red;
            
            //show the menu
            menu.Show(BFS.Input.GetMousePositionX(), BFS.Input.GetMousePositionY());

            //wait for the menu to close
            while(menu.Visible)
                Application.DoEvents();
                
            //dispose the objects
            foreach(ToolStripMenuItem item in menu.Items)
            {
                ClipboardData data = item.Tag as ClipboardData;
                if(data != null)
                    data.Dispose();
                    
                item.Dispose();
            }
        }
        
        return null;
    }
    
    //this function will be called when you click on a regular menu item
    private static void ItemClick(object sender, EventArgs e)
    {
        try
        {
            //get the menu item object
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            if(item == null)
                throw new Exception("ToolStripMenuItem is NULL");
             
            //get the ClipboardData object
            ClipboardData data = item.Tag as ClipboardData;
            if(data == null)
                throw new Exception("ClipboardData is NULL");
            
            //depending on what data we have, set the clipboard
            if(data.Image != null)
            {
                Clipboard.SetImage(data.Image);
                BFS.Clipboard.Paste();
            }
            else if(data.FileList.Length > 0)
            
            {
                StringCollection collection = new StringCollection();
                collection.AddRange(data.FileList);
                Clipboard.SetFileDropList(collection);
                BFS.Clipboard.Paste();
            }
            else
            {            
                BFS.Clipboard.PasteText(data.Text);
            }
        }
        catch(Exception ex)
        {
            //if something happened, show an error
            BFS.Dialog.ShowMessageError(ex.Message);
        }
    }
    
    //this is an object that will store the Clipboard History Item data
    private class ClipboardData : IDisposable
    {
        public string Text;
        public Bitmap Image;
        public string[] FileList;
        
        public ClipboardData(string text, Bitmap image, string[] fileList)
        {
            this.Text = text;
            this.Image = image;
            this.FileList = fileList;
        }
        
        public void Dispose()
        {
            if(this.Image != null)
                this.Image.Dispose();
        }
    }
}

清除剪贴板

Clear the Clipboard 就是清除了当前的剪贴板,但不影响剪贴板记录,就是Ctrl+V的时候粘贴不出东西了。不推荐自用。

This script will clear the current contents of the clipboard.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        BFS.Clipboard.Clear();
        return null;
    }
}

替换: Enter → ,

Comma Delimit by Lines 逗号拼接各行

    This Macro replaces all line breaks with commas.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.Replace("\n", ", ").Replace("\r", "").Trim(new char[] { ',', ' ' });
    }
}

替换: xxx Enter xxxx → "xxx","xxxx"

Comma Delimit by Lines with Quotes 每行加引号后用逗号做分隔符拼接

    This Macro replaces all line breaks with commas surrounded by quotes.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return "'" + text.Trim().Replace("\n", "', '").Replace("\r", "") + "'";
    }
}

在大写/小写/ 首字母大写之间转换(自动复制/粘贴)

Convert betwen Upper/Lower/Titie Case (with auto copy/paste)
编译失败。Line 36: 未能找到类型或命名空间名称“HashSet”(是否缺少 using 指令或程序集引用?)
不推荐自用

    This macro will rotate through upper case, lower case, and title case on the selected text.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Text;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
    private static readonly string[] ExceptionsArray = 
    {   
        //articles
        "a",
        "an",
        "the",
        
        //prepositions (incomplete)
        "on",
        "in",
        "at",
        "for",
        "ago",
        "to",
        "from",
        "by",
        "of",
        "with",
        
        //coordinating conjunctions         
        "and",
        "but",
        "or",
        "nor",
        "for",
        "yet",
        "so"
    };
        
    private static readonly HashSet<string> Exceptions = new HashSet<string>(ExceptionsArray);
    

    public static string ProcessText(string text)
    {   
        //get the highlighted text
        text = BFS.Clipboard.CopyText();
        
        //convert the text to lower case
        string lower = text.ToLowerInvariant();
        
        //if the copied text is lower case, convert it to title case
        if(lower.Equals(text, StringComparison.Ordinal))
        {
            BFS.Clipboard.PasteText(ToTitleCaseSmart(text));
            return null;
        }
        
        //convert to text to title case
        string title = ToTitleCaseSmart(text);
        
        //if the copied text is title case, convert it to upper case
        if(title.Equals(text, StringComparison.Ordinal))
        {
            BFS.Clipboard.PasteText(text.ToUpperInvariant());
            return null;
        }
               
        //otherwise, paste the lower case text
        BFS.Clipboard.PasteText(lower);
        return null;
    }
        
    private static string ToTitleCaseSmart(string text)
    {
        Queue<string> words = new Queue<string>(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(text.ToLowerInvariant()).Split(new char[] { ' ' }));
        

        //Always leave the first word capitalized, regardless of what it is
        StringBuilder builder = new StringBuilder(words.Dequeue());
        
        while(words.Count > 0)
        
        {
            string word = words.Dequeue();
            string lower = word.ToLower();
            builder.Append(" ");
            if(Exceptions.Contains(lower))
                builder.Append(lower);
            else
                builder.Append(word);
        }

        return builder.ToString();
    }
}

转换:骆驼命名法→易读文本(空格隔开)

Convert Camel Case to Readable Text

        This macro converts CamelCase to readable text. 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
public static class ClipboardFusionHelper
{
    public static string ProcessText(string name)
    {
        string input = Regex.Replace(name, "(\\B[A-Z])", " $1");
        return input[0].ToString().ToUpper() + input.Substring(1);
    }
}

替换: , → Enter

Convert Commas to New Lines

        Converts a comma separate list, to a list with one item on each line.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        return new Regex(@"\s*,\s*").Replace(text, "\r\n");
      }
  }

将复制到PGN棋局

Convert Copied Chess Game into PGN

    This macro converts a copied chess game into a PGN format that can be pasted into an analysis GUI (like Chessbase).
    Games can be copied from chess24.com,chess.com or chesskid.com.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)
    {
        Regex rgx = new Regex(@"(\d{1,2})\.?((?:(?:O-O(?:-O)?)|(?:[KQNBR][a-h]?x?[a-h]x?[1-8])|(?:[a-h]x?[a-h]?[1-8]))\+?)((?:(?:O-O(?:-O)?)|(?:[KQNBR][a-h]?x?[a-h]x?[1-8])|(?:[a-h]x?[a-h]?[1-8]))\+?)");
        return rgx.Replace(text, "$1. $2 $3");
    }
}

转换:red→#FF0000

Convert HTML Colour to Hex

    This macro will convert an HTML colour code to a hex value. 例如:red→#FF0000
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;

// 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)
    {
        Color c = ParseColor(text);
        String htmlColor = "#" + c.R.ToString("X2", CultureInfo.InvariantCulture) +
                                 c.G.ToString("X2", CultureInfo.InvariantCulture) +
                                 c.B.ToString("X2", CultureInfo.InvariantCulture);
        if (c.A < 255) htmlColor += c.A.ToString("X2", CultureInfo.InvariantCulture);
        return htmlColor;
    }

    public static Color ParseColor(string htmlColor)
    {
        htmlColor = htmlColor.Trim();

        if (htmlColor.StartsWith("rgb")) // rgb or rgba
        {
            int left = htmlColor.IndexOf('(');
            int right = htmlColor.IndexOf(')');

            if (left < 0 || right < 0)
                throw new FormatException("rgba format error");
            
            string noBrackets = htmlColor.Substring(left + 1, right - left - 1);

            string[] parts = noBrackets.Split(',');

            int r = int.Parse(parts[0], CultureInfo.InvariantCulture);
            int g = int.Parse(parts[1], CultureInfo.InvariantCulture);
            int b = int.Parse(parts[2], CultureInfo.InvariantCulture);

            if (parts.Length == 3)
            {
                return Color.FromArgb(r, g, b);
            }
            else if (parts.Length == 4)
            {
                float a = float.Parse(parts[3], CultureInfo.InvariantCulture);
                return Color.FromArgb((int)Math.Round(a * 255), r, g, b);
            }
        }
        else if ((htmlColor[0] == '#') &&
                ((htmlColor.Length == 9) || (htmlColor.Length == 5)))
        {
            if (htmlColor.Length == 9) 
            {
                string r = htmlColor.Substring(1, 2);
                string g = htmlColor.Substring(3, 2);
                string b = htmlColor.Substring(5, 2);
                string a = htmlColor.Substring(7, 2);
                
                return Color.FromArgb(Convert.ToInt32(a, 16),
                                      Convert.ToInt32(r, 16),
                                      Convert.ToInt32(g, 16),
                                      Convert.ToInt32(b, 16));
            }
            else 
            {
                string r = Char.ToString(htmlColor[1]);
                string g = Char.ToString(htmlColor[2]);
                string b = Char.ToString(htmlColor[3]);
                string a = Char.ToString(htmlColor[4]);
                
                return Color.FromArgb(Convert.ToInt32(a + a, 16),
                                      Convert.ToInt32(r + r, 16),
                                      Convert.ToInt32(g + g, 16),
                                      Convert.ToInt32(b + b, 16));
            }
        }

        return ColorTranslator.FromHtml(htmlColor);
    }
}

转换:red → rgba(255,0,0)

Convert HTML Colour to RGBA

        This macro will convert an HTML colour code to RGBA. 如red → rgba(255, 0, 0)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;

// 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)
    {
        Color c = ParseColor(text);
        String htmlColor = "rgba(" + c.R + ", " + c.G + ", " + c.B + (c.A < 255 ? (c.A / 255.0).ToString("', '#.##;', '#.##;', '0", CultureInfo.InvariantCulture) : "") + ")";
        return htmlColor;
    }
    
    public static Color ParseColor(string htmlColor)
    {
        htmlColor = htmlColor.Trim();

        if (htmlColor.StartsWith("rgb")) // rgb or rgba
        {
            int left = htmlColor.IndexOf('(');
            int right = htmlColor.IndexOf(')');

            if (left < 0 || right < 0)
                throw new FormatException("rgba format error");
            
            string noBrackets = htmlColor.Substring(left + 1, right - left - 1);

            string[] parts = noBrackets.Split(',');

            int r = int.Parse(parts[0], CultureInfo.InvariantCulture);
            int g = int.Parse(parts[1], CultureInfo.InvariantCulture);
            int b = int.Parse(parts[2], CultureInfo.InvariantCulture);

            if (parts.Length == 3)
            {
                return Color.FromArgb(r, g, b);
            }
            else if (parts.Length == 4)
            {
                float a = float.Parse(parts[3], CultureInfo.InvariantCulture);
                return Color.FromArgb((int)Math.Round(a * 255), r, g, b);
            }
        }
        else if ((htmlColor[0] == '#') &&
                ((htmlColor.Length == 9) || (htmlColor.Length == 5)))
        {
            if (htmlColor.Length == 9) 
            {
                string r = htmlColor.Substring(1, 2);
                string g = htmlColor.Substring(3, 2);
                string b = htmlColor.Substring(5, 2);
                string a = htmlColor.Substring(7, 2);
                
                return Color.FromArgb(Convert.ToInt32(a, 16),
                                      Convert.ToInt32(r, 16),
                                      Convert.ToInt32(g, 16),
                                      Convert.ToInt32(b, 16));
            }
            else 
            {
                string r = Char.ToString(htmlColor[1]);
                string g = Char.ToString(htmlColor[2]);
                string b = Char.ToString(htmlColor[3]);
                string a = Char.ToString(htmlColor[4]);
                
                return Color.FromArgb(Convert.ToInt32(a + a, 16),
                                      Convert.ToInt32(r + r, 16),
                                      Convert.ToInt32(g + g, 16),
                                      Convert.ToInt32(b + b, 16));
            }
        }

        return ColorTranslator.FromHtml(htmlColor);
    }
}

转换:img → Base64

Convert Image to Base64

    Converts an image file to a Base64 encoded string.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

// 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)
    {
        if(!Clipboard.ContainsImage())
            return text;
            
        BinaryFormatter binFormatter = new BinaryFormatter();
        using(Image img = Clipboard.GetImage())           
        using(MemoryStream memStream = new MemoryStream())
        {
            binFormatter.Serialize(memStream, img);
            byte[] bytes = memStream.ToArray();
            text = Convert.ToBase64String(bytes);
        }
        
        BFS.Dialog.ShowMessageInfo("Convert image to Base64 is finished!");
        return text;
    }
}

转换:图像 → Base64(HTML标签)

Convert Image to Base64 (Ready for HTML tag) 不推荐自用

        Converts an image to Base64 ready to be used in an HTML tag.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.Text;
using System.Web;

public static class ClipboardFusionHelper
{
    ///<summary>
    /// Base 64 Encoding with URL and Filename Safe Alphabet using UTF-8 character set.
    ///</summary>
    ///<param name="str">The origianl string</param>
    ///<returns>The Base64 encoded string</returns>
    public static string Base64ForUrlEncode(string str)
    {
        byte[] encbuff = Encoding.UTF8.GetBytes(str);
        return HttpServerUtility.UrlTokenEncode(encbuff);
    }
    ///<summary>
    /// Decode Base64 encoded string with URL and Filename Safe Alphabet using UTF-8.
    ///</summary>
    ///<param name="str">Base64 code</param>
    ///<returns>The decoded string.</returns>
    public static string Base64ForUrlDecode(string str)
    {
        byte[] decbuff = HttpServerUtility.UrlTokenDecode(str);
        return Encoding.UTF8.GetString(decbuff);
    } 
    internal static byte[] ImageToByteArray(Image img)
    {
        byte[] byteArray = new byte[0];
        MemoryStream stream = new MemoryStream();
        img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
        stream.Close();
        byteArray = stream.ToArray();
        return byteArray;
    }
    public static string ProcessText(string text)
    {
        if(!Clipboard.ContainsImage())
            return text;
            
        BinaryFormatter binFormatter = new BinaryFormatter();
        using(Image img = Clipboard.GetImage())           
        {
            text = Convert.ToBase64String(ImageToByteArray(img));
        }
        
        //BFS.Dialog.ShowMessageInfo("Convert image to Base64 is finished!");
        return string.Format(@"data:image/gif;base64,{0}", text);
    }
}

转换:多行 → 方括号列表

Convert Multi-Line String to BBCode List(用于BBS论坛中的代码) 不推荐自用

    Takes a string of text (typically multiline text) and converts it to a BBCode list used on nearly all forums. 
    It tries to be smart enough to identify either a ordered list, or unordered list, but it only detects ordered lists if they start at the beginning (i.e., a, i, A, I, 0, or 1). 
    It also tries to account for cutting and pasting lists out of MS Word.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
    {
        public static string ProcessText(string text)
            {
                // takes a string of text (typically multiline text) and converts it to a BBCode list used on nearly all forums
                // it tries to be smart enough to identify either a ordered list, or unordered list, but
                // it only detects ordered lists if they start at the beginning (i.e., a, i, A, I, 0, or 1)
                // it also tries to account for cut'n'pasting lists out of MS Word

                char chrLineIndent = ' '; // default to spaces
                int intLineIndentSize = 2;
                string strListType = "list"; // default to an unordered list
                string strListCSS = "";
                string strOutput = text.Trim();

                // remove multiple white spaces characters and replace them with a single space
                strOutput = Regex.Replace(strOutput, @"[ \t]+", " ");
                
                // remove empty lines ($ doesn't seem to work very well)
                strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})+", "${linebreak}");
                
                // trim the start and end of each line (Regex $ doesn't seem to work very well)
                strOutput = Regex.Replace(strOutput, @"(?:^[ \t]*)|(?:[ \t]*(?<linebreak>[\r\n]{1,2}))", "${linebreak}", RegexOptions.Multiline);
                
                if (Regex.IsMatch(strOutput , @"^[aiAI01][^\w0-9]+"))
                    {
                        // it looks like we are dealing with some sort of ordered list
                        strListType = "ol";
                        
                        // lets work out what type of ordered list it is
                        switch (strOutput[0].ToString())
                            {
                                case "a": strListCSS = "lower-alpha"; break;
                                case "i": strListCSS = "lower-roman"; break;
                                case "A": strListCSS = "upper-alpha"; break;
                                case "I": strListCSS = "upper-roman"; break;
                                case "0": strListCSS = "decimal-leading-zero"; break;
                            }
                        strListCSS = strListCSS.Length > 0 ? "list-style-type:" + strListCSS + ";" : "";
                        

                        // remove the list item indicators
                        strOutput = Regex.Replace(strOutput, @"^[a-zA-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);
                    }

                else if (Regex.IsMatch(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+"))
                    {
                        // it looks like we have some sort of bulleted unordered list
                        // typical bullets include ?, o, ?, #, *, -, ->, =, ?, etc.
                        strListType = "ul";

                        // lets work out what type of unordered list it is
                        switch (strOutput[0].ToString().ToLower())
                            {
                                case "o": strListCSS = "circle"; break;
                                case "[": strListCSS = "square"; break;
                                case "?": strListCSS = "square"; break;
                            }
                        strListCSS = strListCSS.Length > 0 ? "list-style-type:" + strListCSS + ";" : "";
                        

                        // remove the list item indicators
                        strOutput = Regex.Replace(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);
                    }

                string strLineIndent = new string(chrLineIndent, intLineIndentSize);

                // replace line breaks with <li>s (Regex $ doesn't seem to work very well)
                strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})", "[/li]${linebreak}" + strLineIndent + "[li]");
                
                strOutput = String.Format(
                "[{0}{1}]\r\n{2}[li]{3}[/li]\r\n[/{0}]",
                strListType,
                (strListCSS.Length > 0 ? " style=\"" + strListCSS + "\"" : ""),
                
                strLineIndent,
                strOutput
                );

                return strOutput;
        }
    }

转换:多行文本 → HTML'
  • '的列表

Convert Text to HTML List

    Converts the copied text into a HTML list. 
    This Macro takes each line of the copied text and turns it into a HTML list item, then puts them into a HTML ordered or unordered list.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
    
public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // takes a string of text (typically multiline text) and converts it to a HTML list
        // it tries to be smart enough to identify either a ordered list, or unordered list, but
        // it only detects ordered lists if they start at the beginning (ie.a, i, A, I, 0, or 1)
        // it also tries to account for cut'n'pasting lists out of MS Word
        // I've been having trouble with Regex $ - it seems to think the $ is between the \r and the \n, which isn't very helpful
        // this code isn't perfect, but it works well for me
        // use at your own discretion

        char chrLineIndent = '\t';        // default to a tab "\t"
        int intLineIndentSize = 1;
        string strListType = "ul";        // default to an unordered list
        string strListCSS = "";
        string strOutput = text.Trim();

        // remove multiple white spaces characters and replace them with a single space
        strOutput = Regex.Replace(strOutput, @"[ \t]+", " ");

        // remove empty lines ($ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})+", "${linebreak}");

        // trim the start and end of each line (Regex $ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?:^[ \t]*)|(?:[ \t]*(?<linebreak>[\r\n]{1,2}))", "${linebreak}", RegexOptions.Multiline);

        if (Regex.IsMatch(strOutput , @"^[aiAI01][^\w0-9]+"))
        {
            // it looks like we are dealing with some sort of ordered list
            strListType = "ol";

            // lets work out what type of ordered list it is
            switch (strOutput[0].ToString())
            {
                case "a": strListCSS = "lower-alpha"; break;
                case "i": strListCSS = "lower-roman"; break;
                case "A": strListCSS = "upper-alpha"; break;
                case "I": strListCSS = "upper-roman"; break;
                case "0": strListCSS = "decimal-leading-zero"; break;
                case "1": strListCSS = "decimal"; break;
            }
            strListCSS = "list-style-type:" + strListCSS + ";";

            // remove the list item indicators
            strOutput = Regex.Replace(strOutput, @"^[a-zA-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);

        }

        else if (Regex.IsMatch(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+"))
        {
            // it looks like we have some sort of bulleted unordered list
            // typical bullets include •, o, §, #, *, -, ->, =, Ø, etc
            strListType = "ul";

            // remove the list item indicators
            strOutput = Regex.Replace(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);
        }

        string strLineIndent = new string(chrLineIndent, intLineIndentSize);

        // replace line breaks with <li>s (Regex $ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})", "</li>${linebreak}" + strLineIndent + "<li>");

        strOutput = String.Format(
            "<{0}{1}>\r\n{2}<li>{3}</li>\r\n</{0}>",
            strListType,
            (strListCSS.Length > 0 ? " style=\"" + strListCSS + "\"" : ""),
            
            strLineIndent,
            strOutput
            );

        return strOutput;
    }
}

转换:多行文本 → HTML'
  • '的列表(tab转space)

Convert Text to HTML List (revised)

    Converts the copied text into a HTML list. 
    This Macro takes each line of the copied text and turns it into a HTML list item, then puts them into a HTML ordered or unordered list. 
    This revised version uses spaces instead of tabs, and supports a detection of a few other list types.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // takes a string of text (typically multiline text) and converts it to a HTML list
        // it tries to be smart enough to identify either a ordered list, or unordered list, but
        // it only detects ordered lists if they start at the beginning (i.e., a, i, A, I, 0, or 1)
        // it also tries to account for cut'n'pasting lists out of MS Word
        // I've been having trouble with Regex $ - it seems to think the $ is between the \r and the \n, which isn't very helpful
        // this code isn't perfect, but it works well for me
        // use at your own discretion

        char chrLineIndent = ' ';         // default to spaces
        int intLineIndentSize = 2;
        string strListType = "ul";        // default to an unordered list
        string strListCSS = "";
        string strOutput = text.Trim();

        // remove multiple white spaces characters and replace them with a single space
        strOutput = Regex.Replace(strOutput, @"[ \t]+", " ");

        // remove empty lines ($ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})+", "${linebreak}");

        // trim the start and end of each line (Regex $ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?:^[ \t]*)|(?:[ \t]*(?<linebreak>[\r\n]{1,2}))", "${linebreak}", RegexOptions.Multiline);

        if (Regex.IsMatch(strOutput , @"^[aiAI01][^\w0-9]+"))
        {
            // it looks like we are dealing with some sort of ordered list
            strListType = "ol";

            // lets work out what type of ordered list it is
            switch (strOutput[0].ToString())
            {
                case "a": strListCSS = "lower-alpha"; break;
                case "i": strListCSS = "lower-roman"; break;
                case "A": strListCSS = "upper-alpha"; break;
                case "I": strListCSS = "upper-roman"; break;
                case "0": strListCSS = "decimal-leading-zero"; break;
            }
            strListCSS = strListCSS.Length > 0 ? "list-style-type:" + strListCSS + ";" : "";
            

            // remove the list item indicators
            strOutput = Regex.Replace(strOutput, @"^[a-zA-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);

        }

        else if (Regex.IsMatch(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+"))
        {
            // it looks like we have some sort of bulleted unordered list
            // typical bullets include •, o, §, #, *, -, ->, =, Ø, etc.
            strListType = "ul";

            // lets work out what type of unordered list it is
            switch (strOutput[0].ToString().ToLower())
            {
                case "o": strListCSS = "circle"; break;
                case "[": strListCSS = "square"; break;
                case "■": strListCSS = "square"; break;
                case "▪": strListCSS = "square"; break;
            }
            strListCSS = strListCSS.Length > 0 ? "list-style-type:" + strListCSS + ";" : "";
            

            // remove the list item indicators
            strOutput = Regex.Replace(strOutput, @"^[^a-np-zA-NP-Z0-9]+[^\w0-9]+", "", RegexOptions.Multiline);
        }

        string strLineIndent = new string(chrLineIndent, intLineIndentSize);

        // replace line breaks with <li>s (Regex $ doesn't seem to work very well)
        strOutput = Regex.Replace(strOutput, @"(?<linebreak>[\r\n]{1,2})", "</li>${linebreak}" + strLineIndent + "<li>");

        strOutput = String.Format(
            "<{0}{1}>\r\n{2}<li>{3}</li>\r\n</{0}>",
            strListType,
            (strListCSS.Length > 0 ? " style=\"" + strListCSS + "\"" : ""),
            
            strLineIndent,
            strOutput
            );

        return strOutput;
    }
}

转换:文本 → 小写

Convert Text to Lower Case

    Converts the clipboard text to lower case.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.ToLower();
    }
}

转换:文本 → 小写(双模)

Convert Text to Lower Case (dual mode)

    Converts text to lower case. Dual mode: works on selected text or clipboard text if nothing was selected.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;

// Suggested HotKey: Alt + Ctrl + L
public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // Setup.
        string clipboardText = text; // Get clipboard.

        string selectedText = string.Empty;
        BFS.Clipboard.CopyText(out selectedText); // Get selected text.

        if( string.IsNullOrWhiteSpace(selectedText))
        {
            text = clipboardText; // Operate on the clipboard text.
        }
        else
        {
            text = selectedText; // Operate on the selected text.
        }

        // End early if no text found.
        if(string.IsNullOrEmpty(text))
        {
            return null;
        }

        // Main.
        text = text.ToLower();

        // Wrapup.
        BFS.Clipboard.PasteText(text);
        return null;
    }
}

转换:文本 → 小写(自动复制/粘贴)

Convert Text to Lower Case (with auto copy/paste)

    Replaces the selected text with lower case.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
     {
        BFS.Clipboard.CopyText(out text);
        text = text.ToLower();
        BFS.Clipboard.PasteText(text);
        return text;
     }
  }

转换:文本 → 首字母大写

Convert Text to Title Case

    Converts the clipboard text to title case (capitalized first letters).
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using System;
using System.Globalization;
using System.Threading;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        TextInfo TextInfo = Thread.CurrentThread.CurrentCulture.TextInfo;
        return TextInfo.ToTitleCase(text);
    }
}

转换:文本 → 首字母大写(正文、介词保持小写)

Convert Text to Title Case (Smart)

    This macro will convert a string to Title Case, keeping articles and prepositions lower case.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //Words that will not be capitalized; add words to this list as required
        string[] exceptionsArray = { "a", "an", "and", "any", "at", "from", "into", "of", "on", "or", "the", "to", };
      
        List<string> exceptions = new List<string>(exceptionsArray);
        
      
        //Break the input text into a list of capitalized (not upper case) words
        text = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(text.ToLower());
        List<string> words = new List<string>(text.Split(new char[] { ' ' }));
        

        //Always leave the first word capitalized, regardless of what it is
        text = words[0];
        words.RemoveAt(0);
        
        //Check each remaining word against the list, and append it to the new text
        foreach (string s in words)
        {
            if (exceptions.Contains(s.ToLower()))
               text += " " + s.ToLower();    
            else 
               text += " " + s;
        }

        return text;
    }
}

转换:文本 → 首字母大写(自动复制/粘贴)

Convert Text to Title Case (with auto copy/paste)

    Replaces the selected text with title case (capitalized first letters).
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
using System;
using System.Globalization;
using System.Threading;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        BFS.Clipboard.CopyText(out text);
        TextInfo TextInfo = Thread.CurrentThread.CurrentCulture.TextInfo;
        text = TextInfo.ToTitleCase(text);
        BFS.Clipboard.PasteText(text);
        return text;
      }
  }

转换:文本 → 大写

Convert Text to Upper Case

    Converts the clipboard text to upper case.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.ToUpper();
    }
}

转换:文本 → 大写(自动复制/粘贴)

Convert Text to Upper Case (with auto copy/paste)

    Replaces the selected text with upper case.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        BFS.Clipboard.CopyText(out text);
        text = text.ToUpper();
        BFS.Clipboard.PasteText(text);
        return text;
      }
  }

转换:文本 → > 文本(前方加个>号)

Convert to Email Style Quoted Text

    Takes a block of text, adds a line break every ~73 characters (depends on word length), and adds a "greater than" symbol at the start of each line.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Text;

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

        {
            string output = "> ";
            
            int charCount = 0;

            foreach (string word in text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries))
            {
                if ((word.Contains("\n")) || (word.Contains("\r")) || (word.Contains("\0")))
                {
                    string newWord = word.Replace(Environment.NewLine, "\n");
                    newWord = newWord.Replace("\r", "\n");
                    newWord = newWord.Replace("\0", "\n");
                    output += newWord.Replace("\n", Environment.NewLine + "> ") + " ";
                    
                    charCount = newWord.Length + 1;
                }
                else if (charCount > 72 - word.Length)
                
                {
                    output = output.TrimEnd() + Environment.NewLine + "> " + word + " ";
                    

                    charCount = word.Length + 1;
                }
                else
                {
                    output += word + " ";
                    charCount += word.Length + 1;
                }
            }

            return output;
        }
}

将Unicode转换成中文

Convert Unicode to Chinese(不推荐自用)

        This Macro can convert Unicode to Chinese for text.(此代码可以转换 Unicode 为 中文)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)
    {
        System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(text, "\\\\u([\\w]{4})");
        string a = text.Replace("\\u", "");
        char[] arr = new char[mc.Count];
        for (int i = 0; i < arr.Length; i++)
        {
            arr[i] = (char)Convert.ToInt32(a.Substring(i * 4, 4), 16);
        }
        string c = new string(arr);
        BFS.Dialog.ShowMessageInfo(c);
        return c;
    }
}

转换YouTube或Vimeo URL嵌入代码

Convert YouTube/Vimeo URL to Embed Code(不推荐自用)

    Converts standard video service URLs to their embed-code format; very useful for a "full-screen" that only fills the window. 
    Great for portrait monitor layouts when window fills either top or bottom 50% of the screen.
    Works with "youtube.com" or "youtu.be" and "vimeo.com" links. 
    Supports YouTube links which contain a start-time.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Clipboard Fusion Macro: "Convert YouTube/Vimeo URL to Embed Code"
// Michael Seman (@AphixJS)
// v1.0.0
// 2017-02-22

using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string url)
    {
        if (url.Contains("youtube.com") || url.Contains("youtu.be"))
        {
            return ClipboardFusionHelper.ConvertYouTubeToEmbed(url);
        }

        if (url.Contains("vimeo.com"))
        {
            return ClipboardFusionHelper.ConvertVimeoToEmbed(url);
        }

        return url;
    }

    private static string ConvertYouTubeToEmbed(string url)
    {
        string[] parts = url.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
        string idWithPotentialQueryParams = parts[parts.Length - 1].ToString().Replace("?t=","?start=");
        string joiner = idWithPotentialQueryParams.Contains("?") ? "&" : "?";
        string suffix = "ecver=2";
        return "https://www.youtube.com/embed/"+idWithPotentialQueryParams+joiner+suffix;
    }

    private static string ConvertVimeoToEmbed(string url)
    {
        string[] parts = url.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
        string id = parts[parts.Length - 1].ToString();
        return "https://player.vimeo.com/video/"+id;
    }
}

复制并追加

Copy and Append

    This macro allows you to copy and append multiple separate strings.

    Usage:
    Make sure to enable the "Allow Macros to be run multiple times on the same Clipboard text" option on the Settings  Macros tab.
    Copy the first item using Ctrl + C, to ensure the clipboard only contains your first item.
    For subsequent items to be appended, highlight them and run the HotKey that you assigned to this macro.
     When all items have been appended, press Ctrl + V to paste the result.

     说明:
    请确保在“设置-宏”选项卡上启用“允许宏在相同剪贴板文本运行多次”选项。
    使用Ctrl+C复制第一个项目,以确保剪贴板只包含您的第一项。
    要附加的后续项目,高亮显示它们并运行您分配给该宏的热键。
        也就是先清空剪贴板,然后按Ctrl+C复制第一个内容,然后按自定义的快捷键(Win+Alt+小键盘的+号)复制第二个内容,继续这个快捷键第三个内容,最后用Ctrl+V粘贴出即可实现复制并追加
    当所有项目都被追加时,按Ctrl + V来粘贴结果。
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text + BFS.Clipboard.CopyText();
    }
}

去重并按字母排序

De-duplicate and Sort Alphabetically

    This macro will take a comma separated list, de-duplicate the values, and then sort them alphabetically with one value on each line.
    For example, the following input:
    Apples, Pears, Bananas, Apples, Oranges, Pears
    --------------------------------------------
    Would produce the following output:
    Apples
    Bananas
    Oranges
    Pears
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.IO;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
        public static string ProcessText(string text)
        {
                List<string> oItems = new List<String>();
                

                StringReader sr = new StringReader(text);
                string line;
                line= sr.ReadLine();
                while (line != null)
                {
                        string[] parts = line.Split(',');
                        foreach (string strPart in parts) {
                                string strNewPart = strPart.Trim();
                                if (!oItems.Contains(strNewPart )) {
                                        oItems.Add(strNewPart );
                                }
                        }
                        line = sr.ReadLine();
                }
                oItems.Sort();
                return String.Join("\n", oItems.ToArray());
        }
}

解码base64编码的文本(UTF-8)

Decode Base64-Encoded Text (UTF-8) 不推荐自用

    Converts a Base64-Encoded string to plain text.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        byte[] textBytes = System.Convert.FromBase64String(text);
        return System.Text.UTF8Encoding.UTF8.GetString(textBytes);
      }
  }

转换:编码的URL → 易读的

Decode URL-Encoded Text
Converts a URL-Encoded string to a human-readable URL.

1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
    {
      return System.Web.HttpUtility.UrlDecode(text);
    }
  }

衰减值

Decrement Value 不推荐自用

    Takes a numeric or date value and decrements it. 
    Numeric values are decremented by 1.
     Date values are decremented by a single day.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        BFS.Clipboard.PasteText(text)
        If IsNumeric(text) Then
          Dim x As Double = CDbl(text)
         x -= 1
         text = x.ToString()
        ElseIf IsDate(text) Then
          Dim x As DateTime
         x = CDate(text)
         x = x.AddDays(-1.0)
         text = x.ToString("yyyy-MM-dd HH:mm:ss")
        Else
          MessageBox.Show("Clipboard text is invalid.  It must be numeric or a date", "Decrement Value", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

        Return text
    End Function

End Class

编码的文本(UTF-8)使用Base64编码

Encode Text (UTF-8) using Base64-Encoding 不推荐自用

    Converts plain text to a Base64-Encoded string.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        byte[] textBytes = System.Text.UTF8Encoding.UTF8.GetBytes(text);
        return System.Convert.ToBase64String(textBytes);
      }
  }

转换:易读的 → 编码的URL

Encode Text using URL-Encoding

    Converts a human-readable URL to a URL-Encoded string.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        return System.Web.HttpUtility.UrlEncode(text);
      }
  }

产生新的GUID

Generate New Guid

    This macro generates a new guid and puts it on the clipboard.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)
    {
        string guid = System.Guid.NewGuid().ToString();
        string guidstring = String.Format("\"{0}\"",guid);
        return guidstring;
    }
}

从剪贴板获取文件名

Get Filenames from Clipboard

    If you have file objects on the clipboard (i.e. copied from File Explorer), this macro will get their filenames and put them on the clipboard as a text list.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;

// 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)
    {
        //copy the select item
        BFS.Clipboard.Copy();
    
        //if the clipboard contains a file, return its filename
        if((Clipboard.ContainsFileDropList()) && (Clipboard.GetFileDropList().Count > 0))        
        
        {
            //Check if multiple files are selected i.e. more than one)
            if(Clipboard.GetFileDropList().Count > 1)
            
            {
                string FileNames = null;
                
                //Copy all the file names in the selection to FileNames
                for(int fileCount = 0; fileCount < Clipboard.GetFileDropList().Count; fileCount++)
                {
                    FileNames += Path.GetFileName(Clipboard.GetFileDropList()[fileCount]) + Environment.NewLine ;
                }
                return FileNames;
            }
            
            return Path.GetFileName(Clipboard.GetFileDropList()[0]);
        }
        return text;
    }
}

获取上次保存的联机项并粘贴文本

Get Last Saved Online Item and Paste Text 不推荐自用

    Retrieves the last saved ClipboardFusion Online item, sets the clipboard text and then pastes the text into the currently focused application window.

Visual Basic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
      text = BFS.ClipboardFusion.GetLastSavedAPIText()
      If (text.Length > 0)
      
          BFS.Clipboard.PasteText(text)
      End If
        
      Return text
    End Function

End Class

C#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        text = BFS.ClipboardFusion.GetLastSavedAPIText();
        if (text.Length > 0)
        
            BFS.Clipboard.PasteText(text);

        return text;
    }
}

获取上次保存的联机项并设置剪贴板文本

Get Last Saved Online Item and Sets the Clipboard Text 不推荐自用

    Retrieves the last saved ClipboardFusion Online item, sets the clipboard text and then pastes the text into the currently focused application window.

C#

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        if (BFS.ClipboardFusion.GetLastSavedAPIText(out text))
            BFS.Clipboard.SetText(text);

        return text;
    }
}

Visual Basic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        If (BFS.ClipboardFusion.GetLastSavedAPIText(text))
            BFS.Clipboard.SetText(text)
        End If

        Return text
    End Function

End Class

转换:HTML格式→ 论坛代码格式

HTML to UBB code

 Converts HTML formatting to UBB (bulletin/message board) formatting.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

//小恐龙
//ver 1.0
// 转换 html 代码为论坛常用的 ubb 代码.

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        text = Regex.Replace(text, "<br[^>]*>", "\n");
        text = Regex.Replace(text, @"<p[^>\/]*\/>", "\n");
        text = Regex.Replace(text, "\\son[\\w]{3,16}\\s?=\\s*([\'\"]).+?\\1", "");
        text = Regex.Replace(text, "<hr[^>]*>", "[hr]");

        text = Regex.Replace(text, "<(\\/)?blockquote([^>]*)>", "[$1blockquote]");
        text = Regex.Replace(text, "<img[^>]*smile=\"(\\d+)\"[^>]*>", "'[s:$1]");
        text = Regex.Replace(text, "<img[^>]*src=[\'\"\\s]*([^\\s\'\"]+)[^>]*>", "");
        text = Regex.Replace(text, "<a[^>]*href=[\'\"\\s]*([^\\s\'\"]*)[^>]*>(.+?)<\\/a>", "[url=$1]$2[/url]");
        text = Regex.Replace(text, "<b>(.+?)</b>",@"\[b\]$1\[/b\]");
        text = Regex.Replace(text, "<[^>]*?>", "");
        text = Regex.Replace(text, "&", "&");
        text = Regex.Replace(text, " ", " ");
        text = Regex.Replace(text, "<", "<");
        text = Regex.Replace(text, ">", ">");

        return text;
    }
}

inaement价值

Inaement Value

    Takes a numeric or date value and increments it. Numeric values are incremented by 1. Date values are incremented by a single day.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        MacroAPI.PasteText(text)
        If IsNumeric(text) Then
          Dim x As Double = CDbl(text)
         x += 1
         text = x.ToString()
        ElseIf IsDate(text) Then
          Dim x As DateTime
         x = CDate(text)
         x = x.AddDays(1.0)
         text = x.ToString("yyyy-MM-dd HH:mm:ss")
        Else
          MessageBox.Show("Clipboard text is invalid. It must be numeric or a date", "Increment Value", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

        Return text
    End Function

End Class

缩进/取消缩排文本

Indent/Unindent Text

    Use this Macro to indent or unindent text. 
    Use a positive value for indentSize to indent (move text to the right by 1 tab),使用indentsize缩进一个正值(1标签的文字向右移动)
    use a negative value to unindent (move text to the left by 1 tab).使用一个负值来取消缩排(1标签文本向左移动)。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        int indentSize = 1; //Use negative or positve values
        char indentChar = '\t'; //Tab character

        if (indentSize > 0)
        
            text = Regex.Replace(text, @"^", new string(indentChar, indentSize), RegexOptions.Multiline);
        else if (indentSize < 0)
            text = Regex.Replace(text, @"^" + new string(indentChar, Math.Abs(indentSize)), "", RegexOptions.Multiline);

        return text;
    }
}

打开TC并选定剪贴板上的文件或文件夹

Open Files/Folders in Explorer(我已经把资源管理器改为了TC)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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)
    {
        //File Explorer Command Line Parameters can be found here:
        // https://support.microsoft.com/en-us/help/152457/windows-explorer-command-line-options

        //find the first instance of a file list in the clipboard history
        int index = -1;
        for(int i = 0; i < BFS.ClipboardFusion.GetHistoryItemCount(); i++)
        {
            if(!BFS.ClipboardFusion.GetHistoryIndexContainsFileList(i))
                continue;
                
            index = i;
            break;
        }

        //if we couldn't find a file, show a message and exit the macro
        if(index == -1)
        {
            BFS.Dialog.ShowMessageError("There are no files on the Clipboard Manager");
            return null;
        }

        //open File Explorer with selected file highlighted
        //BFS.Application.Start("C:\\Windows\\explorer.exe", string.Format("/select,\"{0}\"", BFS.ClipboardFusion.GetHistoryFileList(index)[0]));
        BFS.Application.Start("C:\\totalcmd\\TOTALCMD64.EXE", string.Format("\"{0}\"", BFS.ClipboardFusion.GetHistoryFileList(index)[0]));

        //let clipboardfusion know that we dont need the clipboard changed
        return null;
    }
}

转换:剪贴板1、2 → 剪贴板1 Enter 剪贴板2 Enter

Paste All History Items with Line Breaks

    Joins all of your history items together into one string, then pastes it into the current window.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //get the number of Clipboard Hisytory Items
        int hisotryItemCount = BFS.ClipboardFusion.GetHistoryItemCount();
        
        //clear the text variable
        text = "";
        
        //add all of the Clipboard History Items to the text variable, separated by a new line character
        for(int i = 0; i < hisotryItemCount; i++)
            text += BFS.ClipboardFusion.GetHistoryText(i) + Environment.NewLine;
        
        //paste the text variable
        BFS.Clipboard.PasteText(text);
        return text;
    }
}

打字粘贴

Paste by Typing

    This macro will enter the clipboard text using SendKeys to type it out, instead of doing a normal paste.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Text;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        BFS.General.ThreadWait(2000);
        StringBuilder sendKeyString = new StringBuilder();
        bool isShiftDown = false;
        foreach(char c in text)
        {
            //smart shift syntax building for letters
            if(char.IsLetter(c) || c == ' ')
            {
                if(char.IsUpper(c) && isShiftDown)
                {
                    sendKeyString.Append(c);
                    continue;
                }
                
                if(char.IsUpper(c) && !isShiftDown)
                {
                    isShiftDown = true;
                    sendKeyString.Append("+(").Append(c);
                    continue;
                }
                
                if(char.IsLower(c) && isShiftDown)
                {
                    isShiftDown = false;
                    sendKeyString.Append(')').Append(char.ToUpperInvariant(c));
                    continue;
                }
                
                if(char.IsLower(c) && !isShiftDown)
                {
                    sendKeyString.Append(char.ToUpperInvariant(c));
                    continue;
                }
            }
            
            if(char.IsDigit(c))
            {
                if(isShiftDown)
                {
                    isShiftDown = false;
                    sendKeyString.Append(')').Append(c);
                    continue;
                }
                
                sendKeyString.Append(c);
                continue;
            }
            
            //turn off smart shift here
            if(isShiftDown)
            {
                isShiftDown = false;
                sendKeyString.Append(')');
            }
            
            //this part will only work with en-us keyboards
            switch(c)
            {
                case '~':
                    sendKeyString.Append("+(`)");
                    break;
                case '!':
                    sendKeyString.Append("+(1)");
                    break;
                case '@':
                    sendKeyString.Append("+(2)");
                    break;
                case '#':
                    sendKeyString.Append("+(3)");
                    break;
                case '$':
                    sendKeyString.Append("+(4)");
                    break;
                case '%':
                    sendKeyString.Append("+(5)");
                    break;
                case '^':
                    sendKeyString.Append("+(6)");
                    break;
                case '&':
                    sendKeyString.Append("+(7)");
                    break;
                case '*':
                    sendKeyString.Append("+(8)");
                    break;
                case '(':
                    sendKeyString.Append("+(9)");
                    break;
                case ')':
                    sendKeyString.Append("+(0)");
                    break;
                case '_':
                    sendKeyString.Append("+(-)");
                    break;
                case '+':
                    sendKeyString.Append("+(=)");
                    break;
                case '{':
                    sendKeyString.Append("+([)");
                    break;
                case '}':
                    sendKeyString.Append("+(])");
                    break;
                case '|':
                    sendKeyString.Append("+(\\)");
                    break;
                case ':':
                    sendKeyString.Append("+(;)");
                    break;
                case '"':
                    sendKeyString.Append("+(')");
                    break;
                case '<':
                    sendKeyString.Append("+(,)");
                    break;
                case '>':
                    sendKeyString.Append("+(.)");
                    break;
                case '?':
                    sendKeyString.Append("+(/)");
                    break;              
                default:
                    sendKeyString.Append(c);
                    break;
            }
        }
        
        BFS.Input.SendKeys(sendKeyString.ToString());
        return text;
    }
}

只粘贴日期

Paste Date Only

    Takes a date time value and pastes only the date. The original date time value stays on the clipboard.

Visual Basic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        If IsDate(text) Then
          Dim x As DateTime = CDate(text)
            BFS.Clipboard.PasteText(x.ToString("yyyy-MM-dd"))
        Else
          MessageBox.Show("Clipboard text is invalid.  It must be a date", "Paste Date Only", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

        Return text
    End Function

End Class

粘贴第一个历史项

Paste First History Item

    This macro will paste the first item in the history menu.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        text = BFS.ClipboardFusion.GetHistoryText(0);
        BFS.Clipboard.PasteText(text);
        return text;
    }
}

粘贴最旧的历史项并移除

Paste Oldest History Item and Remove

    This Macro will paste the oldest History item and remove it from the history when done.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        int count = BFS.ClipboardFusion.GetHistoryItemCount();
        
        //--pull entire history into temporary array    
        string[] history = BFS.ClipboardFusion.GetAllHistoryText();
                
        //--if any history
        if(count > 0)
        
        {
            //--paste the oldest entry
            text = BFS.ClipboardFusion.GetHistoryText(count - 1);
            BFS.Clipboard.PasteText(text);
        
            //--now clear history
            BFS.ClipboardFusion.ClearHistory();
            
            //--then rebuild from temporary array
            for(int i = count - 2; i >= 0; i--)
            {
                BFS.ClipboardFusion.AddHistoryText(history[i]);
            }
        }

        return null;
    }
}

在腻子中粘贴第二个历史项

Paste Second History Item in PuTTY

        This script will paste the second history item into PuTTY, while still keeping the order of the history items, so that a normal right-click will always paste the first history item.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string textnew)
        {
            string textold;
            textnew = BFS.ClipboardFusion.GetHistoryText(0);
            textold = BFS.ClipboardFusion.GetHistoryText(1);

            BFS.Clipboard.SetText(textold);

            BFS.Input.RightClickMouse();
            //BFS.Clipboard.Paste();

            BFS.Clipboard.SetText(textold);

            return   textnew;
        }
}

只粘贴时间

Paste Time Only

    Takes a date time value and pastes only the time. The original date time value stays on the clipboard.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        If IsDate(text) Then
          Dim x As DateTime = CDate(text)
            BFS.Clipboard.PasteText(x.ToString("hh:mm:ss tt"))
        Else
          MessageBox.Show("Clipboard text is invalid.  It must be a date", "Paste Time Only", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

        Return text
    End Function

End Class

在复制的文本进行文字gount

Perform a Word Gount on the Copied Text

    Takes the copied clipboard text and perform a word count (among other things). 
    A message box is displayed showing the statistics for your copied text.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Windows.Forms;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // Name:                Word Count
        // Description:    Pops up a message box that shows some statistics about the text on the clipboard, such as word count, number of characters, number of lines, etc.


        // which message layout do we want to display?
        // feel free to add your own layouts below
        int intLayout = 1;    // possible values are 1 or 2

        // create an array of our objects
        // you can add more here as needed, but there may be limited space to display the results in the message box that pops
        objWordCount[] arrWordCount = new objWordCount[2];
        arrWordCount[0] = new objWordCount("Text", text);
        arrWordCount[1] = new objWordCount("No HTML Tags", HttpUtility.HtmlDecode(Regex.Replace(text, @"<[\w\W]+?>", string.Empty)));

        // string used to store our word count message
        string strMessage = string.Empty;

        // different layouts can be added here
        // depending on your OS, you may have to tweak the layouts a little bit
        switch(intLayout)
        {
            default:

                // this is the default layout

                // create our word count message
                for(int i = 0; i < arrWordCount.Length; i++)
                {
                    strMessage +=
                        (arrWordCount[i].title.ToUpper() + " ").PadRight(50, '\x2013') + "\r\n" +
                        "Words " + ("  " + arrWordCount[i].words.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Characters " + ("  " + arrWordCount[i].chars.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Characters (no spaces) " + ("  " + arrWordCount[i].charsNoSpaces.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Characters (no breaks) " + ("  " + arrWordCount[i].charsNoBreaks.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Characters (no breaks or spaces) " + ("  " + arrWordCount[i].charsNoSpacesBreaks.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Lines " + ("  " + arrWordCount[i].lines.ToString()).PadLeft(12, '_') + "\r\n" +
                        "Average characters per word \x2009" + ("  " + (String.Format("{0:0.0}",((double)arrWordCount[i].charsNoSpacesBreaks / (double)arrWordCount[i].words)))).PadLeft(12, '_') + "\r\n" +
                        "Average characters per line \x2009" + ("  " + (String.Format("{0:0.0}",((double)arrWordCount[i].charsNoBreaks / (double)arrWordCount[i].lines)))).PadLeft(12, '_') + "\r\n" +
                        "Average words per line \x2009" + ("  " + (String.Format("{0:0.0}",((double)arrWordCount[i].words / (double)arrWordCount[i].lines)))).PadLeft(12, '_') + "\r\n" +
                        "\r\n\r\n";
                }

                break;

            case 2:

                // this layout has a problem if there are more then two word count objects, use the default layout instead

                // set the length of our titles to a maximum of 12 characters (we can't have them being too long in this layout)
                for(int i = 0; i < arrWordCount.Length; i++)
                {
                    if(arrWordCount[i].title.Length > 12) arrWordCount[i].title = arrWordCount[i].title.Substring(0, 12);
                    
                }

                // create our word count message
                strMessage = string.Empty;
                strMessage += "Clipboard Word Count";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (arrWordCount[i].title).PadLeft(12, '\x2002');
                strMessage += "\r\n" + new string('\x203E', 60) + "\r\nWords";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].words.ToString()).PadLeft(12, '_');
                strMessage += "\r\n\r\nCharacters";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].chars.ToString()).PadLeft(12, '_');
                strMessage += "\r\nCharacters (no spaces)";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].charsNoSpaces.ToString()).PadLeft(12, '_');
                strMessage += "\r\nCharacters (no breaks)";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].charsNoBreaks.ToString()).PadLeft(12, '_');
                strMessage += "\r\nCharacters (no spaces or breaks)";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].charsNoSpacesBreaks.ToString()).PadLeft(12, '_');
                strMessage += "\r\n\r\nLines";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + (" " + arrWordCount[i].lines.ToString()).PadLeft(12, '_');
                strMessage += "\r\n\r\nAverage characters per word";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + "\x2009" + (" " + String.Format("{0:0.0}",((double)arrWordCount[i].charsNoSpacesBreaks / (double)arrWordCount[i].words))).PadLeft(12, '_');
                strMessage += "\r\nAverage characters per line";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + "\x2009" + (" " + String.Format("{0:0.0}",((double)arrWordCount[i].charsNoBreaks / (double)arrWordCount[i].lines))).PadLeft(12, '_');
                strMessage += "\r\nAverage words per line";
                for(int i = 0; i < arrWordCount.Length; i++) strMessage += new string(' ', 5) + "\x2009" + (" " + String.Format("{0:0.0}",((double)arrWordCount[i].words /(double)arrWordCount[i].lines))).PadLeft(12, '_');

                break;
        }

        // display our word count message box
        MessageBox.Show (
            strMessage.Trim(),
            "Clipboard Word Count".PadRight(100, '\x2002'),
            MessageBoxButtons.OK,
            MessageBoxIcon.None,
            MessageBoxDefaultButton.Button1,
            MessageBoxOptions.RightAlign
            );

        // we don't want to alter the original text on the clipboard, so return the same text as we received
        return text;
    }

}

public class objWordCount
{
    public string title;
    public int pages;
    public int words;
    public int chars;
    public int charsNoSpaces;
    public int charsNoBreaks;
    public int charsNoSpacesBreaks;
    public int lines;

    public objWordCount(string strTitle, string strInput)
    {
        title               = strTitle;
        pages               = new Regex(@"\f", RegexOptions.Multiline).Matches(strInput).Count + 1;  // based on form feed characters, not very common these days
        words               = new Regex(@"\b\w+\b", RegexOptions.Multiline).Matches(strInput).Count;
        chars               = strInput.Length;
        charsNoSpaces       = Regex.Replace(strInput, @"[ \t\v]", string.Empty).Length;
        charsNoBreaks       = Regex.Replace(strInput, @"[\f\r\n]", string.Empty).Length;
        charsNoSpacesBreaks = Regex.Replace(strInput, @"[\s]", string.Empty).Length;
        lines               = new Regex(@"[\n\r]{1,2}", RegexOptions.Multiline).Matches(strInput).Count + 1;
    }
}

纯膏+ Spotify糊

Pure Paste + Spotify Paste

    Pastes the embedded artist/album/song text in Spotify URI's.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Windows.Forms;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        string retVal = text;

        bool isHtmlDataOnClipboard = Clipboard.ContainsData(DataFormats.Html);
        if (isHtmlDataOnClipboard)
          {
            string htmlText = Clipboard.GetText(TextDataFormat.Html);

            // Spotify link detection:
            if (htmlText.ToLower().StartsWith( "version:" ) &&
            (htmlText.ToLower().Contains("<a href=\"spotify") ||
            htmlText.ToLower().Contains("<a href=\"http://open.spotify.com")))
              {
                string hrefSubstring = htmlText.Substring(htmlText.IndexOf("<a href", 0, StringComparison.InvariantCultureIgnoreCase));
                int indexOfLinkTitle = hrefSubstring.IndexOf('>') + 1; // Index of '>' in the opening <a href> tag + 1.
                
                int indexOfHrefEndtag = hrefSubstring.IndexOf("</a>", 0,StringComparison.InvariantCultureIgnoreCase);
                int lengthOfLinkTitle = indexOfHrefEndtag - indexOfLinkTitle; // Obtained by factoring out hrefSubstring.Length in the following statement: hrefSubstring.Length - indexOfLinkTitle - (hrefSubstring.Length - indexOfHrefEndtag);

                retVal = hrefSubstring.Substring(indexOfLinkTitle, lengthOfLinkTitle);

                // Handle special characters.
                retVal = System.Web.HttpUtility.HtmlDecode( retVal );
              }
          }

        BFS.Clipboard.PasteText(retVal);
        return retVal;
      }
  }

从制表符分隔的数据引用CSV输出

Quoted CSV Output From Tab Delimited Data

    Takes tab delimited data (including data copied from Excel), and converts it into a comma separated values (CSV) or comma delimited format where each field is surrounded by quotes. 
    This helps in situations where each field in a CSV file needs to be quoted since saving a file as a CSV from Excel will only place quotes around fields that happen to have commas in them. 
    There are no options in Excel to quote all output.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        System.Text.StringBuilder output = new System.Text.StringBuilder();
        System.IO.StringReader sr = new System.IO.StringReader(text);
      string line = null;

        line = sr.ReadLine();
      while (line != null)
      {
          string[] parts = line.Split('\t');
          output.AppendFormat("{0}{1}{0}{2}", '"', String.Join("\",\"", parts), "\n");
            line = sr.ReadLine();
      }

        return output.ToString();
    }
}

去除多余的空白和装饰

Remove Extra White Spaces and Trim

    This macro will remove double-spaces and trim white space from the beginning and end of the copied text.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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();
      }
  }

从文本中删除换行符(自动复制粘贴)

Remove Linebreaks from Text (with auto copy-paste)

    This macro copies currently selected text, removes any line breaks, then pastes the modified text back.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Text;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //copy whatever is selected to the clipboard
        //this will allow this macro to be used more quickly
        text = BFS.Clipboard.CopyText();
        
        //make sure all of the line breaks are the same type
        text = text.Replace(Environment.NewLine, "\n");
        text = text.Replace("\r", "\n");
        text = text.Replace("\0", "\n");
        
        //this will let us quickly build the string to return
        StringBuilder builder = new StringBuilder();
        
        //split the text up into its separate lines
        foreach(string line in text.Split(new char[]{'\n'}, StringSplitOptions.RemoveEmptyEntries))
        {
            //this is probably redundant since we are removing empty entries
            //if the line variable is null or empty, continue to the next line
            if(string.IsNullOrEmpty(line))
                continue;
                
            //if the line is blank, ignore it
            if(IsLineOnlyWhiteSpace(line))
                continue;
                
            //add the line to the StringBuilder
            builder.AppendLine(line);
        }
        
        //paste the StringBuilder
        BFS.Clipboard.PasteText(builder.ToString());
        
        //tell ClipboardFusion to put the StringBuilder on the clipboard
        return builder.ToString();
    }
    
    //this is a set of blank characters
    private static readonly Dictionary<char, int> WhiteSpaceChars = new Dictionary<char, int>
    
    {
        {' ', 0},
        {'\x0085', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {' ', 0},
        {'\x200B', 0},
        {' ', 0},
        {'\xFEFF', 0},
        {'\v', 0},
        {'\f', 0},
        {'\x2028', 0},
        {'\x2029',  0},
    };
    
    //this function returns true if a line is composed of only whitespace or blank characters
    private static bool IsLineOnlyWhiteSpace(string line)
    {
        foreach(char c in line)
        {   
            if(!WhiteSpaceChars.ContainsKey(c))
                return false;
        }
        
        return true;
    }
}

删除不包含特定文本的行

Remove Lines That Don't Contain Specific Text

    This macro searches text line by line, and removes any line that doesn't contain "google."
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Text;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //make sure all of the line breaks are the same
        //replace CRLF with LF
        text = text.Replace(Environment.NewLine, "\n");
        
        //replace CR with LF
        text = text.Replace("\r", "\n");
        
        //create a variable to store the edited text
        StringBuilder builder = new StringBuilder();
        
        //split the text up by the LF character ('\n') and loop through it
        foreach(string line in text.Split(new char[]{'\n'}, StringSplitOptions.RemoveEmptyEntries))
        {
            //if the line doesn't have the string "google" in it, ignore the line
            if(line.IndexOf("google", StringComparison.OrdinalIgnoreCase) == -1)
                continue;
                
            //add the line to the variable
            builder.AppendLine(line);
        }

        //return all of the lines that contain "google"
        return builder.ToString();
    }
}

用空格替换句点(点)

Replace Period (Dot) with a Space

    This macro will replace all periods with a space.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        if (text.Contains("."))
        {
            return text = text.Replace(".", " ");
        }
        
        return text;
    }
}

用空格和自动粘贴替换句点(点)

Replace Period (Dot) with a Space and Auto-Paste

    This macro will replace all periods with a space and auto-paste the result to the last focused text box.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        BFS.Clipboard.CopyText(out text);
        if (text.Contains("."))
        {
            text = text.Replace(".", " ");
        }
        
        BFS.Clipboard.PasteText(text);
        return null;
    }
}

用连字符替换空格

Replace Spaces with Hypens

    This macro will replace all spaces with hyphens.
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.Replace(" ", "-");
    }
}

用连字符替换特殊字符

Replace Special Characters with Hyphens

    Replaces special characters with hyphens. Useful for cleaning up file names.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
             return text.Replace(" ","-")     //space
                        .Replace(":","-")     //colon
                        .Replace(";","-")     //semi-colon
                        .Replace("\\","-")    //Backslash
                        .Replace("/","-")     //Slash
                        .Replace("&","-")     //Ampersand
                        .Replace("%","-")     //Percent
                        .Replace("?","-")     //QuestionMark
                        .Replace("—","-")     //Em dash
                        .Replace("–","-")     //En dash (kindof redundant)
                        .Replace("“","-")     //Smart Quote
                        .Replace("”","-")     //Smart Quote
                        .Replace("’","-")     //Typographic apostrophe
                        .Replace("[","-")     //Left Bracket
                        .Replace("]","-")     //Right Bracket
                        .Replace("®","-")     //Registered TradeMark
                        .Replace("*","-")     //star
                        .Replace("#","-");    //number sign / pound / hash / Octothorp
    }
}

与Windows EOL取代UNIX EOL

Replace UNIX EOL with Windows EOL

    Converts Unix end-of-line (LF) to Windows end-of-line (CRLF)
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.Replace("\n","\r\n");
    }
}

与UNIX的EOL取代Windows EOL

Replace Windows EOL with Unix EOL

    Replaces Windows end-of-line (CRLF) with Unix end-of-line (LF)
1
2
3
4
5
6
7
8
9
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        return text.Replace("\r\n","\n");
    }
}

恢复剪贴板内容

Restore Clipboard Contents

    Restores the previous clipboard contents after pasting from a ClipboardFusion list.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Windows.Forms;

// 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)
    {
        if(Clipboard.ContainsData("CF_CLIPBOARDFUSION_ITEM_SET"))
        {
            text = BFS.ScriptSettings.ReadValue("RestoreText");
            if(!string.IsNullOrEmpty(text))
                Clipboard.SetText(text);
        }
        else
        {
            text = Clipboard.GetText();
            if(string.IsNullOrEmpty(text))
                BFS.ScriptSettings.WriteValue("RestoreText", "");
            else
                BFS.ScriptSettings.WriteValue("RestoreText", Clipboard.GetText());
        }
        
        return null;
    }
}

将复制的映像保存到磁盘

Save Copied Image to Disk

    If the current item in the clipboard is an image, running this macro will save the image to the disk in the folder you specify in the path variable.
    By default, the path is set to your Desktop.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Windows.Forms;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        string userprofilepath, path, name, filename, time;
        userprofilepath = Environment.GetEnvironmentVariable("userprofile");
        // Update the path below to the folder where you would like the images saved (i.e. path = "C:\\Images\\"; or path = userprofilepath + "\\Pictures\\";))
        path = userprofilepath + "\\Desktop\\";
        name = "ClipboardFusion Saved Picture";
        if (Clipboard.ContainsImage())
            {
                time = DateTime.Now.ToString("(yyyy.MM.dd HH.mm.ss)");
                filename = path + name + " " + time + ".png";
                MessageBox.Show("Saving picture to " + filename, "ClipboardFusion",
                MessageBoxButtons.OK, MessageBoxIcon.Information);
                Clipboard.GetImage().Save (@filename,
                System.Drawing.Imaging.ImageFormat.Png);
            }
        else
            MessageBox.Show ("The clipboard does not contain a picture.",
            "ClipboardFusion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            return text;
    }
}

擦洗展望电子邮件地址

Scrub Outiook Email Addresses

    When you copy an Outlook contact's email address, you typically get this:
                  John Doe
    Use this Macro to reduce this to:
                  [email protected]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        Regex email = new Regex(@"[<\[](?<email>[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4})[>\]];?", RegexOptions.IgnoreCase);
        string textNew = text;
        if (email.Match(text).Success)
        {
            textNew = "";
            foreach(Match match in email.Matches(text))
                textNew += match.Groups["email"] + " ";
        }
        return textNew;
    }
}

用于复制的文本使用Bing.com搜索

Search For Copied Text using Bing.com

    This Macro will launch your default web browser and search Bing.com for the text currently on the clipboard.

VB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://www.bing.com/search?q={0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

用于复制的文本使用在线搜索

Search For Copied Text using Dictionary.com

    This Macro will launch your default web browser and search Dictionary.com for the text currently on the clipboard.

VB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://dictionary.reference.com/browse/{0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

用于复制的文本使用Google.com搜索

Search For Copied Text using Google.com

This Macro will launch your default web browser and search Google.com for the text currently on the clipboard.

VB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://www.google.com/search?q={0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

用于复制的文本使用stackoverflow.com搜索

Search For Copied Text using StackOverflow.com

This Macro will launch your default web browser and search StackOverflow.com for the text currently on the clipboard.

VB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://stackoverflow.com/search?q={0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

用于复制的文本使用thesaurus.com搜索

Search For Copied Text using Thesaurus.com

    This Macro will launch your default web browser and search Thesaurus.com for the text currently on the clipboard.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://thesaurus.com/browse/{0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

用于复制的文本使用yahoo.com搜索

Search For Copied Text using Yahoo.com

This Macro will launch your default web browser and search Yahoo.com for the text currently on the clipboard.

VB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://search.yahoo.com/search?p={0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

发送剪贴板内容到 Pastebin 网站

Send Clipboard Contents to Pastebin(需要访问pastebin网站)
这里我定义了个快捷键为 Win+Alt+Num-(小键盘的减号)

This macro sends the contents of your clipboard to Pastebin as a new paste, and returns the new Pastebin URL to your clipboard for immediate pasting.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.IO;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        System.Collections.Specialized.NameValueCollection Data = new System.Collections.Specialized.NameValueCollection();

        Data["api_paste_name"] = "ClipboardFusion Paste";

        // Defaults to 1 day, can be changed. See Pastebin API  N =从不,     10M = 10分钟,     1H = 1小时,     1D = 1天,     1W = 1周,     2W = 2周,     1M = 1个月,     6M = 6个月,     1Y = 1年
        //Data["api_paste_expire_date"] = "1D";
        Data["api_paste_expire_date"] = "N";
        Data["api_paste_code"] = text;

        // 0 = public, 1 = unlisted, 2 = private
        //Data["api_paste_private"] = "1";
        Data["api_paste_private"] = "2";

        //下面填写API密钥(注意保密哦~)地址在这里查看 https://pastebin.com/api#1  
        Data["api_dev_key"] = "<API Key>";
        Data["api_option"] = "paste";

        using( WebClient wb = new WebClient() )
        {
            byte[] bytes = wb.UploadValues( "https://pastebin.com/api/api_post.php", Data );

            string response;
            using ( MemoryStream ms = new MemoryStream( bytes ) )
            using ( StreamReader reader = new StreamReader( ms ) )
                response = reader.ReadToEnd();

            if ( response.StartsWith( "Bad API request" ) )
            {
                BFS.Dialog.ShowMessageInfo("Failed to upload. Response: " + response);
                return text;
            }
            else
            {
                BFS.Dialog.ShowMessageInfo("Sent to Pastebin. URL in clipboard.");
                return response;
            }
        }
    }
}

分享链接到脸书

Share Link on Facebook

Shares the copied link on Facebook.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
Imports System

Public Class ClipboardFusionHelper

    Public Shared Function ProcessText(text As String) As String
        Dim url as String = "http://www.facebook.com/share.php?u={0}"
        url = String.Format(url, text.Replace(" "c, "+"c))
        System.Diagnostics.Process.Start(url)
        Return text
    End Function

End Class

缩短YouTube链接

Shorten YouTube Link

This macro shortens a YouTube video from the full https://www.youtube.com/watch?v= to the youtu.be version.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
using System;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        Regex youtubeRegex = new Regex(@"https://www\.youtube\.com\/watch\?v\=(?<id>[^\&]*)(?:\&.*)?");
        Match match = youtubeRegex.Match(text);

        if (!match.Success) {
            // If this isn't a YouTube video, don't do anything to it
            return text;
        }

        Group idGroup = match.Groups["id"];
        string idText = idGroup.Value;
        return "https://youtu.be/" + idText;
    }
}

显示历史下拉列表,修改和粘贴选定的项目

Show History Drop-Down List, Modify and Paste Selected Item

This Macro will show a drop-down list that contains the items in the ClipboardFusion History. 
After choosing an item from the list and clicking OK, the item is manipulated (in this example, it's wrapped in  tags for pasting URLs into HTML code), and then pasted into the last active textbox.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        // get the number of items in the history
        int count = BFS.ClipboardFusion.GetHistoryItemCount();
        if (count <= 0)
        {
            // show an error and return if there are no items
            BFS.Dialog.ShowMessageError("Sorry, there are no items currently in your History.");
            return "";
        }
        
        // build the history selection dialog by getting each item in the history
        List<string> items = new List<string>();
        
        for (int a=0; a<count; a++)
            items.Add(BFS.ClipboardFusion.GetHistoryText(a));
            
        // show the history selection dialog
        text = BFS.Dialog.GetUserInputList("Select a History Item", items.ToArray());
        
        // if the user cancels, return without doing anything
        if (text.Length == 0)
            return "";
        
        // generate the return text using the value the user selected (in this case it's an HTML link)
        text = "<a href=\"" + text + "\" target=\"_blank\"><b>XXXX</b></a>";
        
        // paste the generated text into the currently active window
        BFS.Clipboard.PasteText(text);
        return text;
    }
}

显示宏列表

Show List of Macros

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.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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) colorQ
**- "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);
        }
    }
}

求和所有的值

Sum All Values

    Takes a list of values separated by line endings and sums all the values if it can.
    A message box will be shown with the summed value.  If not all values are numeric, you will receive an additional warning, but the numeric values will still be summed.  
    The summed value is then placed in the clipboard.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.IO;
using System.Windows.Forms;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        StringReader sr = new StringReader(text);
      bool notAllValuesAreNumeric = false;
      double summedValues = 0.0;
      string lineStringVal;
      lineStringVal= sr.ReadLine();
      while (lineStringVal != null)
      {
          double val;
          if (Double.TryParse(lineStringVal, out val))
             summedValues += val;
            else
                notAllValuesAreNumeric = true;
            
            lineStringVal = sr.ReadLine();
        }

        string message = "Sum: " + summedValues.ToString();
        if (notAllValuesAreNumeric)
          message += "\n!!!NOTE: Not All Values were numeric.!!!";

      MessageBox.Show(message, "Sum of All Lines", MessageBoxButtons.OK, MessageBoxIcon.Information);
        return summedValues.ToString();
    }
}

装饰线

Trim All Lines

    Takes a list of values and trims each line so that there is no white space remaining on either side of each line. 
    The line endings still remain.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        System.IO.StringReader sr = new System.IO.StringReader(text);
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        string line;
        int count = 0;
        int failSafe = 100000; //Set Failsafe to 100,000 so that we'll break after that many tries

        line = sr.ReadLine();
        while (line != null)
        {
            sb.AppendLine(line.Trim());
            line = sr.ReadLine();
            count += 1; //increment count and check if we're in an infinite loop
            if (count == failSafe)
                return "Failed.\nFail Safe At: " + failSafe.ToString() + "\nCopy Fewer Lines";
        }
        return sb.ToString();
    }
}

按行的唯一值

Unique Values by Line

Takes a list of values and returns only the unique values in the list. 
The unique value list is placed in the clipboard.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        System.IO.StringReader sr = new System.IO.StringReader(text);
      string line = null;
      List<string> values = new List<string>();
      

        line = sr.ReadLine();
      while (line != null)
        {
          if (!values.Contains(line)) values.Add(line);
            line = sr.ReadLine();
        }

      return String.Join("\n", values.ToArray());
    }
}

URL抓取

URL Grabber

This macro will grab all of the text between [] or  characters.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Text;
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
{
    public static string ProcessText(string text)
    {
        //this regular expression grab text between [] or <> characters
        
        string urlMatchRegex = "((?<=\\[).*?(?=\\]))|((?<=<).*?(?=>))";
        
        //a variable to store our modifications to the clipboard
        StringBuilder builder = new StringBuilder();
        
        //search the text for URLs
        foreach(Match match in Regex.Matches(text, urlMatchRegex, RegexOptions.IgnoreCase))
        {
            //a check to make sure we found a URL
            if(match.Length == 0)
                continue;
            
            //add the URL to the variable
            builder.AppendLine(match.ToString());
        }
        
        //return our modified text to the clipboard
        return builder.ToString();
    }
}

URL洗涤器

URL Scrubber

Cleans up long URLs.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
using System.Text.RegularExpressions;

public static class ClipboardFusionHelper
  {
    public static string ProcessText(string text)
      {
        text = Regex.Replace(text,
        @"(https?://www\.google\.[a-z.]+/search)(?(?=\?tbm=)(\?(tbm=[^&\s]*).*?(&q=[^&\s]*))|((?=.*?[?&](q=[^&\s]*))(?=.*?(&tbm=[^&\s]*))*))[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
        "$1?$2$3$5$6");
        text = Regex.Replace(text,
        @"(https?://maps\.google\.[a-z.]+/maps)(?(?=\?q=)(\?(q=[^&\s]*)(?=.*?(&(?:s?ll|z|t)=[^&\s]*))*)|((?=.*?[?&](q=[^&\s]*))(?=.*?(&(?:s?ll|z|t)=[^&\s]*))*))[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
        "$1?$2$3$5$6");
        text = Regex.Replace(text,
        @"(https?://www\.youtube\.com/watch).*?[?&](v=[^&\s]*)[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
        "$1?$2");
        text = Regex.Replace(text,
        @"(https?://www\.amazon\.[a-z.]+).*?(/(dp|gp/product|exec/obidos/ASIN)/[A-Z0-9]+)[a-zA-Z0-9-_./~*%$@:;,!?&=+#]*",
        "$1$2/");
        return text;
      }
  }