以编程方式控制鼠标光标和鼠标单击 [英] Control mouse cursor and mouse click programmatically

查看:134
本文介绍了以编程方式控制鼠标光标和鼠标单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想编写一个Visual C#程序,该程序能够以编程方式在屏幕上定位鼠标光标,并自动在该位置执行mouseclick.我正在使用Visual Studio 2005.

Hi, I would like to write a Visual C# program which is able to programmatically position the mouse cursor on the screen and perform a mouseclick on the location automatically. Im using visual studio 2005.

感谢您的帮助.

推荐答案

1.使用Position属性将光标移动到所需的位置(例如50,50).2.使用表单单击事件处理程序"执行所需的操作. 1. private void button1_Click(object sender,EventArgs e){Cursor.Position = new Point(50,50);点击+ = new EventHandler(ClickEventHandler); ClickEventHandler(sender,new EventArgs()); } 2. void ClickEventHandler(object sender,EventArgs e){MessageBox.Show("hi"); }
1. Use Position Property to move the cursor to the desired location (say 50,50) 2. Use Form Click Event Handler to do the desired action. 1. private void button1_Click(object sender, EventArgs e) { Cursor.Position = new Point(50, 50); this.Click += new EventHandler(ClickEventHandler); ClickEventHandler(sender, new EventArgs()); } 2. void ClickEventHandler(object sender, EventArgs e) { MessageBox.Show("hi"); }


这篇关于以编程方式控制鼠标光标和鼠标单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆