C# 剪贴板问题,列表中有几个问题

C# 剪贴板问题,列表中有几个问题,c#,clipboard,C#,Clipboard,我的问题 我有一个程序,列表中有很多问题。我想用一个剪贴板来回答这些问题。但我的程序中有50多个问题,有时我的列表中的一些问题没有得到回复,我该如何解决 这是我的代码 protected override void WndProc(ref Message m) { base.WndProc(ref m); //check if current operation is a clipboard if (m.Msg == WM_DRAWCLIPBOARD) {

我的问题
我有一个程序,列表中有很多问题。我想用一个剪贴板来回答这些问题。但我的程序中有50多个问题,有时我的列表中的一些问题没有得到回复,我该如何解决

这是我的代码

protected override void WndProc(ref Message m)
{
    base.WndProc(ref m);

    //check if current operation is a clipboard
    if (m.Msg == WM_DRAWCLIPBOARD)
    {

        //then we use a try catch block so if 
        //anything wrong happens in Clipboard.GetText() our program wont crash
        try
        {
            //with foreach we go through all our questions
            foreach (string question in questionList)
                //with foreach we go through all our questions

                {
                //and we check if clapboarded text is matches with our question
                if (Clipboard.GetText() == "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?")
                {
                    notifyIcon1.Icon = SystemIcons.Exclamation;
                    notifyIcon1.BalloonTipTitle = "When a computer is being assembled, which action can be taken to help eliminate cable clutter within a computer case?";
                    notifyIcon1.BalloonTipText = "Install a modular power supply.*";
                    notifyIcon2.BalloonTipIcon = ToolTipIcon.Error;
                    notifyIcon1.ShowBalloonTip(100);
                    Clipboard.Clear();
                    return;
                }

这对我来说很有效,所以我很确定有时候你的两个条件中有一个不符合

const int WM_DRAWCLIPBOARD = 36;
protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);

        //check if current operation is a clipboard
        if (m.Msg == WM_DRAWCLIPBOARD)
        {
            try
            {
                if (Clipboard.GetText() == "123")
                {
                    MessageBox.Show(Clipboard.GetText());
                    Clipboard.Clear();
                    return;
                }
            }
            catch(Exception e)
            {

            }
        }
   } 

请澄清您的意图,我不清楚您试图实现的目标。我希望只有在我突出显示并复制了答案上的问题(使用ctrl+c复制)时,才会弹出windows通知。但我把很多问题列在一个清单上,有时我得不到回报。我不知道如何解决这个问题,我猜@TeunvandenBroek-正在开发一些测试/考试应用程序。如果用户/考生试图复制问题(因此称为“剪贴板”),然后想在线搜索问题(以便作弊)。他想阻止这一点。你有没有收到任何错误,或者代码运行平稳但没有返回?如果是这种情况,我想<代码>剪贴板.GETTrEXE()=问题< /代码>此条件不满足。您需要考虑的另一点是,什么阻止您的用户部分地复制问题(这样,您的剪贴板与问题字符串不一样),然后作弊。