Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As you see my timer check if user click ctrl+ mouse middle, after timer1() send ctrl+c keys to active program and get selected text to textbox1 but sometimes get some my MessageBoxs text content why? How can I solve this problem

Such as Textbox1 text content

C#
---------------------------
Message Title
---------------------------
Message
---------------------------
OK
---------------------------


private void timer1_Tick(object sender, EventArgs e){
            if (comboBox1.SelectedIndex == 0 && hotkey.Ctrl_Middle()) //ctrl+mouse middle
            {
                timer_1();
            }
}


C#
void timer_1(){
            string clp = "";
            if (!Clipboard.GetText().Contains(" -MessageBox text content -")) 
            {
                clp = Clipboard.GetText(); //Old clipboardtext backup
            }
            SendKeys.Send("^c");
            if (!string.IsNullOrWhiteSpace(Clipboard.GetText()) && Clipboard.GetText() != clp)
            {
                textBox1.Text = Clipboard.GetText();  //***************
            }
            
            if (!string.IsNullOrWhiteSpace(clp))
            {
                try
                {
                    Clipboard.SetText(clp);
                }
                catch (Exception)
                {
                    MessageBox.Show("Error : " + clp);
                }
            }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900