简体   繁体   English

区分用户生成的和我自己的应用程序生成的鼠标移动

[英]Distinguish between user generated and my own application generated mouse moves

My WinForms app moves the mouse cursor about the form simply by setting the Cursor.Position property in some kind of a loop with a timer. 我的WinForms应用程序只需在某种形式的带有计时器的循环中设置Cursor.Position属性,即可在窗体上移动鼠标光标。

I would like this movement to continue only till the user does not wield the mouse himself to move it. 我希望这种运动能够继续下去,直到用户自己不挥动鼠标来移动它。 As soon as he or she does, I want my code to stop. 只要他或她这样做,我就希望我的代码停止。

Therefore, I need a way to distinguish between mouse moves that the user generated mouse movement sent vs. those that my application generates. 因此,我需要一种方法来区分用户生成的鼠标移动和应用程序生成的鼠标移动

If you use the Win32 SendInput API to position the mouse cursor, you can set a custom dwExtraInfo value in the MOUSEINPUT structure. 如果使用Win32 SendInput API定位鼠标光标,则可以在MOUSEINPUT结构中设置自定义dwExtraInfo值。

When processing an asynchronous (posted) message, you can use the Win32 API GetMessageExtraInfo to retrieve the custom value. 处理异步(已发布)消息时,可以使用Win32 API GetMessageExtraInfo检索自定义值。

A straightforward solution for Windows 8 and up: use the GetCurrentInputMessageSource function. Windows 8及更高版本的直接解决方案:使用GetCurrentInputMessageSource函数。

if originId is IMO_INJECTED , the input is emulated. 如果originIdIMO_INJECTED ,则模拟输入。 Otherwise, it usually equals IMO_HARDWARE . 否则,它通常等于IMO_HARDWARE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用EF生成的模型和我自己的模型 - Working with EF Generated Model and My Own Model 创建自己的字符串格式表达式,用于自定义用户生成的输出 - Creating own string format expressions, for custom user generated output 如何区分用户输入,但允许应用程序本身更改文本 - How to distinguish between user input, but allow the application itself to change text 将用户生成的查询传递给n层应用程序 - Passing a user generated query down an n-tiered application 用户生成的规范 - User's generated specifications 我想在我生成的预制件之间添加空间 - i want to add space between my generated prefabs 我的连接字符串在其自己生成的连接字符串上出错。 我该如何解决? - My connectionstring is erroring on its own generated connection string. how would i fix this? 我如何使自己的Web API手动或强制生成的访问令牌失效 - How i can expire the access-token manually or forcefully generated by my own web API 如何将我自己的参数添加到http生成的请求中 <form> 在ASP .NET MVC中? - How to add my own parameters to http get request, generated by <form> in ASP .NET MVC? 如何添加自己的代码以及表单设计器生成的代码? - How can I add my own code along with the code generated by the form designer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM