4

I created a mouse-centered magnifier in autohotkey with the windows magnifier api. Done back in windows 7, worked over the new windows 8, 8.1, and even 10 LTSB. But it appears to break in windows 10 creators update, redstone 3 update, this carried on to windows 10 redstone 4, and now Windows 10 Redstone 5. Of course, no answers found.

The problem is that while magnified, clicking certain location of the screem causes the clicking position as if it's not there, outside the screen, or nowhere, defocusing the window.

I tested with the magnifier api sample from https://code.msdn.microsoft.com/windowsdesktop/Magnification-API-Sample-14269fd2 Also tested with simple C# console application below;

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);
    }
}

I tested it on another computer installed with windows 10 redstone 4, still same.

Anyone know what's up with it, why it happens, and how to fix it?

Lance U. Matthews
  • 15,725
  • 6
  • 48
  • 68
Kei
  • 121
  • 1
  • 10
  • I've also run into this. It appears that the built in magnifier tool does not suffer from this bug, so it must be using some kind of double secret not broken technique. – Rick Velde May 17 '19 at 23:08

1 Answers1

0

Okay, I discovered what's the problem here after so long.

After some new major Windows 10 update, the function "MagSetInputTransform" started to affect mouse as well in such a way that it's bugged.

UIA access is needed to get this function to work, it's a hassle but I was dealing with 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)

For additional info, I couldn't use my Wacom drawing tablet while magnified as it bugs out with this MagSetInputTransform. I've yet to discover to fix this yet.

Hope this bit of info helps anyone coming across.

Kei
  • 121
  • 1
  • 10
  • Since this was the solution to your problem, there's nothing wrong with and it is recommend to [accept](https://stackoverflow.com/help/accepted-answer) your own answer. I reverted your edit to the question title, though, because accepting an answer is the proper way to convey that a solution was found. – Lance U. Matthews Dec 02 '19 at 00:00