4

我使用 windows magnifier api 在 autohotkey 中创建了一个以鼠标为中心的放大镜。在 Windows 7 中完成,在新的 Windows 8、8.1 甚至 10 LTSB 上工作。但它似乎在 Windows 10 创建者更新、红石 3 更新中中断,这继续到 Windows 10 红石 4 和现在的 Windows 10 红石 5。当然,没有找到答案。

问题是,在放大时,单击屏幕的某个位置会导致单击位置好像它不存在、屏幕之外或无处,从而使窗口散焦。

我使用来自https://code.msdn.microsoft.com/windowsdesktop/Magnification-API-Sample-14269fd2的放大镜 api 示例 进行了测试,还使用下面的简单 C# 控制台应用程序进行了测试;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Runtime.InteropServices;

namespace Magnifier
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(MagInitialize());
            Console.WriteLine(MagSetFullscreenTransform(4.0f, 0, 0));
            Console.ReadLine();
            MagUninitialize();
        }

        [DllImport("Magnification.dll")]
        public static extern bool MagInitialize();

        [DllImport("Magnification.dll")]
        public static extern bool MagSetFullscreenTransform(float a, int b, int d);

        [DllImport("Magnification.dll")]
        public static extern bool MagUninitialize();

        [DllImport("Magnification.dll")]
        public static extern bool MagShowSystemCursor(bool a);
    }
}

我在另一台安装了 Windows 10 redstone 4 的计算机上对其进行了测试,仍然相同。

任何人都知道它是怎么回事,为什么会发生,以及如何解决它?

4

1 回答 1

0

好的,经过这么长时间,我发现了这里的问题。

在一些新的主要 Windows 10 更新之后,“MagSetInputTransform”函数也开始以这种方式影响鼠标,以至于它被窃听。

需要 UIA 访问才能使此功能正常工作,这很麻烦,但我正在处理 Autohotkey。

; offset_x and offset_y is the magnification origin (top-left)
; SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN is the maximum screen size
; If A_LastError returns 5, it means access denied and needs UIA permission (beyond administrator permission, so it won't work with just administrator privilege)

VarSetCapacity(rect_source, 16)
VarSetCapacity(rect_destination, 16)

NumPut(offset_x, rect_source, 0, "Int")
NumPut(offset_y, rect_source, 4, "Int")
NumPut(offset_x + SM_CXVIRTUALSCREEN / zoom_factor, rect_source, 8, "Int")
NumPut(offset_y + SM_CYVIRTUALSCREEN / this.zoom_factor, rect_source, 12, "Int")

NumPut(0, rect_destination, 0, "Int")
NumPut(0, rect_destination, 4, "Int")
NumPut(0 + SM_CXVIRTUALSCREEN, rect_destination, 8, "Int")
NumPut(0 + SM_CYVIRTUALSCREEN, rect_destination, 12, "Int")

If (!DllCall("Magnification.dll\MagSetInputTransform", "Int", 1, "Ptr", &rect_source, "Ptr", &rect_destination))
     Msgbox, % "Magnifier`nError " A_LastError)

有关更多信息,我无法在放大时使用我的 Wacom 绘图板,因为它与这个 MagSetInputTransform 有问题。我还没有发现要解决这个问题。

希望这一点信息可以帮助任何遇到的人。

于 2019-11-30T14:26:32.180 回答