模拟鼠标移动(C#)
我将如何制作一个不断向上移动鼠标的小程序?
对于那些想知道的人来说,这是一个小小的一次性的东西。我正在玩《星球大战:原力释放》。在控制台版本中,您将向上握住右摇杆。在 PC 上的坏控制台端口中,您正在使用鼠标。也许你能理解我的沮丧。
How would I go about making a small program that keeps moving the mouse upwards?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SetCursorPos
将在非托管代码中执行此操作。我不确定是否有 .NET 方法可以执行相同的操作,但您始终可以使用 com 互操作。它位于 User32.dll 中,谷歌将其生成为 SetCursorPos 相当于 .net
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.dlla little google produces this as a SetCursorPos equivalent for .net
这是机械编程的问题,而不是 CSharp 的问题。
并获得便宜的变速有线
钻头。
钻孔,用条纹纸包起来,
并将其设置为最低速度。
将固定钻头的主体
鼠标的传感器靠近
旋转条纹纸。
模拟向上运动。
要执行该程序,请翻转电钻所插入的电源板上的电源开关。
编辑:如果您想要更便携的代码,请使用无绳电钻。不含电池。
This is a problem for mechanical programming, not CSharp.
and get a cheap variable speed corded
drill.
drill, wrap it with striped paper,
and set it to the lowest speed.
body of the drill that will hold the
mouse with its sensor close to the
spinning striped paper.
simulate an up movement.
To execute the program, flip the power switch on the power strip the drill is plugged into.
Edit: if you want more portable code, use a cordless drill. Batteries not included.
我不知道这个游戏,但 Windows 内部会发出鼠标移动的消息。这些由
SendMessage()
API 调用发送到应用程序。在 C# 中,您要么必须直接使用相同的 Win32 API,要么可能通过创建/发送事件?但不确定如何将事件发送到另一个正在运行的应用程序。C# 中定义的 SendMessage() Win32 API 调用如下所示:
I don't know the game but internally windows sends out messages for mouse move. These are sent by the
SendMessage()
API call to the application. In C# you would either have to use the same Win32 API directly or perhaps by creating/sending an event? Not sure how to send an event to another running application though.The SendMessage() Win32 API call defined in C# would look like this: