阻止/取消鼠标移动/点击C# [英] Block/Nullify mouse movement/click in C#
问题描述
我正在编写一个应用程序,以完全控制鼠标的点击/移动。
I am writing an application to fully control the mouse click/movement.
例如,如果我有应用程序运行,形式完全透明,全屏,然后if我单击鼠标按钮,在正常情况下,它会带来应用程序在后台焦点 - 我需要停止这种情况发生(即单击按钮,没有可见应该发生在屏幕上),因为我需要处理所有的鼠标
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 (i.e. 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.
我需要允许2鼠标独立操作,我使用它作为覆盖,创建2个假指针通过绘图使用C#,禁用真正的鼠标。
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.
推荐答案
你所指的是鼠标捕获 - Windows Forms以及WPF和WinAPI。
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.
这里是在WinForms中执行此操作。
在WinAPI级别,您可以使用 SetCapture(HWND w)函数调用。
At the WinAPI level you can use the SetCapture( HWND w ) function call.
这篇关于阻止/取消鼠标移动/点击C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!