简体   繁体   English

阻止/取消鼠标移动/在C#中单击

[英]Block/Nullify mouse movement/click in C#

I am writing an application to fully control the mouse click/movement. 我正在编写一个可以完全控制鼠标单击/移动的应用程序。

For instance, if I have the application running, form fully transparent, fullscreen, then if I click the mouse button, in normal case, it will bring the application in background in focus - I need to stop this from happening (ie clicking the button and nothing visible should happen on the screen), as I need to process all the mouse activity and send it out using this application. 例如,如果我有正在运行的应用程序,则窗体完全透明,全屏,那么如果我单击鼠标按钮,在正常情况下,它将使应用程序聚焦在后台-我需要阻止这种情况的发生(即,单击按钮并且在屏幕上什么都看不见),因为我需要处理所有鼠标活动并使用此应用程序将其发送出去。

I need to allow 2 mouse to act independently, and I am using this as an overlay, creating 2 fake pointers by drawing using C#, whist disabling the real mouse. 我需要允许2个鼠标独立运行,并且我将其用作覆盖,通过使用C#绘制来创建2个虚假指针,从而禁用了真正的鼠标。

What you are referring to is called mouse capture - and it can be done it both Windows Forms as well as WPF and WinAPI directly. 您所指的是所谓的鼠标捕获-可以在Windows窗体以及WPF和WinAPI中直接完成。

Here's the way to do it in WinForms . 这是在WinForms中完成的方法

At the WinAPI level you can use the SetCapture( HWND w ) function call. 在WinAPI级别上,可以使用SetCapture(HWND w)函数调用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM