How do you simulate Mouse Click in C#?

后端 未结 7 1093
长情又很酷
长情又很酷 2020-11-22 05:34

How do you simulate Mouse clicks in C# winforms applications?

7条回答
  •  醉梦人生
    2020-11-22 06:20

    they are some needs i can't see to dome thing like Keith or Marcos Placona did instead of just doing

    using System;
    using System.Windows.Forms;
    
    namespace WFsimulateMouseClick
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                button1_Click(button1, new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, 1, 1, 1));
    
                //by the way
                //button1.PerformClick();
                // and
                //button1_Click(button1, new EventArgs());
                // are the same
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("clicked");
            }
        }
    }
    

提交回复
热议问题