如何使用C#来移动鼠标光标? [英] How to move mouse cursor using c#?

查看:140
本文介绍了如何使用C#来移动鼠标光标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想模拟鼠标移动每x秒。
为此,当计时器滴答我要让鼠标的移动,我会用一个定时器(x秒)和

I want to simulate mouse movement every x seconds. For that, I'll use a timer (x seconds) and when the timer ticks I'll make the mouse movement.

但是,我怎么能使用C#使鼠标光标移动?

But, how can I make the mouse cursor move using c#?

在此先感谢:)

推荐答案

看看的<一个href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx\"><$c$c>Cursor.Position物业。它应该让你开始。

Take a look at the Cursor.Position Property. It should get you started.

private void MoveCursor()
{
   // Set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form. 

   this.Cursor = new Cursor(Cursor.Current.Handle);
   Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
   Cursor.Clip = new Rectangle(this.Location, this.Size);
}

这篇关于如何使用C#来移动鼠标光标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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