我试过寻找这个问题的答案,但我一直不幸试图找到它 .
从这里的类似问题我已经能够使我的透明窗口接收鼠标事件,但是后面运行的其他应用程序没有得到任何鼠标事件(将窗口的背景设置为#01000000(大多数是透明的)) .
或者替代方案我也实现了:the transparent window gets no mouse events and they are all passed through .
有没有办法结合这两个并有一个透明的窗口,既可以解释鼠标事件,也可以将它们传递给它背后的任何东西? My end goal would be to display a ping graphic on the transparent window (which is the same width/height of my desktop resolution) any time the mouse is clicked on the screen while I'm using other applications.
进一步编辑:
我的WPF窗口中有一个Canvas . 它有MouseLeftButtonDown作为调用后面代码中的方法的元素 . 当我使用我链接的解决方案时,或者只是将Window和Canvas设置为Transparent或#00000000时,似乎不会调用此方法 .
1 回答
我认为更好的方法是使用windows hook来捕获全局鼠标事件,并简单地让你的应用程序放弃鼠标命中测试 . 据我所知,Windows框架中不能直接使用Windows钩子,但它们是PInvokable .
Microsoft为此提供了一个非常简单的指南here .