使用剪贴板选择句子的一部分而不是整个句子



我想要我的程序,而不是选择整个句子进行返回,如果复制了句子的一部分,也可以

。这是我的代码:

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)
{
//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);
return;
}

这是个问题:"组装计算机时,可以采取哪些措施来帮助消除计算机机箱内的电缆杂乱?

例如,如果您复制了以下内容,我想要:组装计算机时,哪个

您会收到相同的匹配项和相同的通知

提前致谢

使用字符串方法。包含 (( 而不是相等比较。

if (Clipboard.GetText().Contains(yourString))

最新更新