本文介绍了高DPI缩放比例,鼠标钩和WindowFromPoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置SetWindowsHookEx(WH_MOUSE_LL,,,)右键单击钩子的进程.我的过程在两个监视器上都以150%的比例在Window 10.0.10586上设置为DPI系统感知.通过调用SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)进行设置.

I have a process that sets a SetWindowsHookEx(WH_MOUSE_LL, , ,) right click hook. My process is set to DPI system aware on Window 10.0.10586 at 150% scaling on both monitors. This was set by calling SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE).

我的问题情况是Office 2007没有DPI,因此我们将MS Word放置在屏幕的右四分之一处.右键单击右下角任务栏上方,鼠标钩将发送坐标1279、675-缩放为Word.然后我右键单击Visual Studio(DPI感知),在整个屏幕上将近四分之三,鼠标钩向我发送例如Visual Studio的1279、1008.因此,如果我在屏幕上方单击较高的位置,则可能会得到相同的1279、675.

My problem scenario is e.g. Office 2007 is DPI unaware, so let's place MS Word on the right quarter of the screen. Right click just above the task bar in the bottom right and the mouse hook sends coordinates of 1279, 675 - scaled to Word. Then I right click on visual studio (DPI aware), nearly three quarters across the screen and the mouse hook sends me coordinates of e.g. 1279, 1008 from Visual Studio. So if I clicked higher up the screen I would potentially get the same 1279, 675.

我的过程试图通过调用WindowFromPoint API来确定哪个窗口在该点上,但是在这种情况下,这显然会失败,因为两个应用程序共享"同一点.

My process is trying to determine which window is at the point by calling the WindowFromPoint API, but this will clearly fail in this scenario as two applications "share" the same point.

是否可以强制鼠标挂钩始终发送原始物理坐标,而不是缩放到不了解DPI的应用程序?如果是这样,怎么办?另外,还有其他方法可以通过鼠标挂钩来确定hWnd或processID吗?

Is it possible to force the mouse hook to always send raw physical coordinates instead of those scaled to the DPI unaware application? and if so, how? Alternately, is there some other way of determining the hWnd or processID from the mouse hooks?

推荐答案

Microsoft在10.0.14393中对其进行了修复.

Microsoft fixed it in 10.0.14393.

除非您的客户机号在LTSB 10.0.10240上,否则您的网络中应该没有任何东西.

You should have nothing in your client's network now with a lower build number unless they are on LTSB 10.0.10240.

这是解决方案:可识别DPI的屏幕截图

这篇关于高DPI缩放比例,鼠标钩和WindowFromPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:12