Control the mouse cursor using C#

ぐ巨炮叔叔 提交于 2019-12-20 13:19:41

问题


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!


回答1:


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);

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




回答2:


Have a look at the Cursor class

http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(v=VS.100).aspx




回答3:


You will have to write a client application that us run on the remote machine to receive your mouse movement command messages. That client application will then take control of the mouse, and move it to commanded coordinates.

There are several applications that allow remote desktop control. Microsoft supplies at least a couple (Netmeeting, Remote Desktops). VNC is another popular tool. Joel has his CoPilot built on VNC.



来源:https://stackoverflow.com/questions/4082770/control-the-mouse-cursor-using-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!