模拟鼠标移动(C#) [英] Simulating mouse movement (C#)

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

问题描述

我如何去制作一个小程序,不断向上移动鼠标?

How would I go about making a small program that keeps moving the mouse upwards?


对于那些想知道是谁,TT的一个微小的一次性使用的东西。我在玩星球大战原力释放。在家用机版,你会向上按住右棒。在的控制台PC上的端口,你用你的鼠标。也许你能理解我的无奈。

For those who would like to know, tt's a tiny one-use thing. I'm playing Star Wars The Force Unleashed. In console versions, you would hold the right stick upwards. In the bad console port on the PC, you're using your mouse. Maybe you can understand my frustration.

推荐答案

SetCursorPos 将做到这一点非托管代码。我不知道是否有一个.NET方法做同样的,但你可以随时使用COM互操作。它在User32.dll中

SetCursorPos will do this in unmanaged code. I'm not sure if there's a .NET method to do the same, but you can always use com interop. It's in User32.dll

[DllImport("user32.dll")]
static extern bool SetCursorPos(int X, int Y);



一点谷歌产生这个作为的SetCursorPos相当于.NET

System.Windows.Form.Cursor.Position

这篇关于模拟鼠标移动(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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