Writing a clipboard viewer in C#

删除回忆录丶 提交于 2019-12-05 06:27:19

问题


I want to write program to learn vocabulary. Simply each time, when I copy a word to clipboard, It will save them to text file.

so, there are requirements, I think that is:

  1. My program run in background like keylogger?
  2. Detect even and save words to text file everytime I copy a word to clipboard.?

all done by C#. so, plz give me some advice! thank you very much!


回答1:


There's an example in the .NET SDK called ClipboardSpy.

Here's an example even:

static void Main(string[] args)
{
    while (true)
    {
        if (Clipboard.ContainsText())
        {
            string s = Clipboard.GetText();

            Console.WriteLine(s);

            Clipboard.Clear();
        }
    }
}



回答2:


Detect even and save words to text file everytime I copy a word to clipboard.?

To detect clipboard changes use the SetClipboardViewer.

Here are instructions of how to create a clipboard viewer in C#: Create a Windows Clipboard Monitor in C# using SetClipboardViewer



来源:https://stackoverflow.com/questions/1236783/writing-a-clipboard-viewer-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!