Block/Nullify mouse movement/click in C#

给你一囗甜甜゛ 提交于 2019-12-18 09:49:24

问题


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 (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.

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.


回答1:


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.

Here's the way to do it in WinForms.

At the WinAPI level you can use the SetCapture( HWND w ) function call.



来源:https://stackoverflow.com/questions/1179197/block-nullify-mouse-movement-click-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!