简体   繁体   English

如何在SCREEN上获取鼠标WM_MouseMove消息?

[英]How do I get mouse WM_MouseMove Message on SCREEN?

Now I'm working on a project which require me to get mouse moving message from all time. 现在,我正在一个项目上,该项目需要我始终获取鼠标移动消息。 My app only have a tiny windows for configuration purpose and it will not even appear on the desktop for most of the time. 我的应用程序只有一个用于配置目的的小窗口,并且在大多数情况下甚至都不会出现在桌面上。 What I need is I need to be able to record mouse moving on desktop. 我需要的是能够记录鼠标在桌面上的移动。 meaning people moving their mouse on the desktop (which should be explorer.exe ,right?) and I need to know. 意思是人们在桌面上移动鼠标(应该是explorer.exe,对吗?),我需要知道。

How do I do that? 我怎么做? Using c# or C++. 使用c#或C ++。 using inject? 使用注入? Global hook? 全局钩子? I heard that only c++ supports global hook, right? 我听说只有c ++支持全局钩子,对吗?

Yes, you need a global hook, and as far as I know you should use C or C++. 是的,您需要一个全局钩子,据我所知,您应该使用C或C ++。

See the docs about function SetWindowsHookEx() & co. 请参阅有关函数SetWindowsHookEx()和co的文档。 (WH_MOUSE hook). (WH_MOUSE钩子)。

But beware! 但是要当心! You must write a global hook in a DLL, and it will get injected in every process with a window, so any bad thing you do will likely crash any other program in your session (including explorer.exe, devenv.exe, etc.). 您必须在DLL中编写一个全局钩子,并且该钩子将在每个进程中注入一个窗口,因此您做的任何坏事都可能会使会话中的任何其他程序崩溃(包括explorer.exe,devenv.exe等)。 。

You can also use SetCapture . 您也可以使用SetCapture Although it's capabilities are limited compared to a hook, check it out. 尽管与钩子相比,它的功能有限,但请检查一下。

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

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