使用C#控制鼠标光标 [英] Control the mouse cursor using C#

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

问题描述

我正在尝试使用C#编写程序,这将允许我远程控制在Windows机器上的鼠标。这将允许我发出命令到鼠标移动到屏幕的某一部分,然后点击屏幕的那部分。我想知道是否有任何C#类,我将有助于实现这一目标。任何帮助是赞赏。谢谢!

I'm trying to write a program using C# that would allow me to remotely take control of the mouse on a windows machine. This would allow me to issue commands to the mouse to move to a certain part of the screen and then click on that part of the screen. I was wondering if there were any C# classes that I would be useful in achieving this goal. Any help is appreciated. Thanks!

推荐答案

我认为除非你只是将光标放在自己的应用程序上,你必须使用windows api调用。你可以在C#中引用:

I think unless you're just positioning the cursor over your own application, you have to use a windows api call. You can reference that in C# as such:

[DllImport("user32")]
public static extern int SetCursorPos(int x, int y);

有一个更完整的Win32包装类的源代码这里

There's source code for a more complete Win32 wrapper class here

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

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