Unable to send keys of Magnifier of Windows 10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Unable to send keys of Magnifier of Windows 10

Post by A Keymaker » 22 Mar 2023, 08:17

I have tried using method after method which in the end accumulated to this repetetive code

Code: Select all

Run magnify.exe
  WinWait Magnifier
  WinActivate Magnifier

  Sleep 1111

  Send {LWin down}{+}{+}{LWin Up}

  Send {RWin down}{+}{+}{LWin Up}

  Send {LWin}+{+}
  Send {LWin}+{+}

  Send {RWin}+{+}
  Send {RWin}+{+}

  Send {Tab}{Enter}{Enter}

  Send #{+}
  Send #{+}

  Send <#{+}
  Send <#{+}

  Send >#{+}
  Send >#{+}

  Send LWin{+}
  Send LWin{+}

  Send RWin{+}
  Send RWin{+}
  
  Return
and still all I get is Magnifier being opened and even focused - but with no changes to it. It just opens with the last used level of zoom and stays like it. But if I then manually press e.g. TAB+ENTER+ENTER then the window of magnify.exe program responds to it properly i.e. [in this example] by jumping o the + button and pressing it twice [thus zooming in 2 levels]. And if during that 1 second time delay I switch to some other window, then my string of keys is sent to it

And yes- I have checked if magnify.exe is elevated or no: it is no
Last edited by A Keymaker on 22 Mar 2023, 14:13, edited 2 times in total.

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Unable to send keys of Magnifier of Windows 10

Post by A Keymaker » 22 Mar 2023, 09:14

A Keymaker wrote:
22 Mar 2023, 08:17
[...]
And yes- I have checked if magnify.exe is elevated or no: it is no
For whatever ill reason all I had to do was to run the AHK script As Administrator - which is illogical because the target program is not run with privileges

But even then there are issues as when I run the code in such version

Code: Select all

Run magnify.exe
WinWait Magnifier
WinActivate Magnifier

Sleep 333

Send >#{+}
Sleep 66

Send >#{+}
Sleep 66

Send >#{+}
Sleep 66

Send >#{+}

Return
then sometimes it executes the + button 3 times while other times 4 or 2 - which inconsistency is of course unacceptable, because the whole point of such scripts is to be able to run Magnifier with a certain level of zoom already applied to it as it starts

Prior to turning to AutoHotkey I tried using Command Prompt, but magnify.exe /? shows nothing

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Unable to send keys of Magnifier of Windows 10

Post by A Keymaker » 22 Mar 2023, 10:21

Afer trying out different versions, this below seems to be OK [i.e. consistent in outcome of its repeated executions]

Code: Select all

Sleep 222

Send >#{+}
Sleep 111

Send >#{+}
Sleep 111

Send >#{+}
Sleep 111

Send >#{+}
and so I can use it for 200% as I use increments [i.e. zooming steps] of 25% and also easily prepare other version like 300% or 150%, right? Well, not actually

Because the above makes +200% and not just 200%. And so I would be forced to use in also with a delayed and extended zooming out, so that it would accommodate for a hypothetical zooming in that occurred when Magnifier was last used. And so, assuming that I would never go deeper than 400%, that part of script for +200% would need to be preceded with this:

Code: Select all

Loop, 16
{
    Send >#{-}
    Sleep 111
}
But this would require from me waiting patiently for all that queued keys to be executed, before being sure that in the end the outcome will be +200%. What is also staggering here is that when I manually press Enter or click Left Mouse Button on the + button within window of Magnifier then it gets executed the right amount of time

So a question arises: why some keys sent through AHK [without a custom tailored Sleep] get omitted while when manually pressed multiple times Enter gets queued on some list that will then spit them out precisely one-by-one?

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Unable to send keys of Magnifier of Windows 10

Post by off » 22 Mar 2023, 20:09

@A Keymaker
You only missing one thing my man :D

Code: Select all

Run magnify.exe
WinWait, ahk_class Screen Magnifier Window

Send, #{= 2}
; Send, #{+ 2} ; this have no effect, because its sending Win + Shift + =
Return
try this code, and see if it works.
tried in Win 10, works perfectly
Last edited by off on 22 Mar 2023, 20:17, edited 1 time in total.
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

User avatar
A Keymaker
Posts: 455
Joined: 31 May 2022, 13:46
Location: Donjon du Château de Mérovingien

Re: Unable to send keys of Magnifier of Windows 10

Post by A Keymaker » 22 Mar 2023, 20:09

A Keymaker wrote:
22 Mar 2023, 10:21
[...]
So a question arises: why some keys sent through AHK [without a custom tailored Sleep] get omitted while when manually pressed multiple times Enter gets queued on some list that will then spit them out precisely one-by-one?
Whatever the answer might be - I have looked for shortcuts for magnify.exe and found this document https://support.microsoft.com/en-us/windows/magnifier-keyboard-shortcuts-and-touch-gestures-6d7c3095-75ec-258f-6f5b-3b0bc19a18e7 which says, that apparently there is a one for resetting of the zoom to 100% / zero. So then I was able to substitute the above insert with an alternative approach as too what and how should be looped

And so now the whole code looks like this:

Code: Select all

If !A_IsAdmin
Run *RunAs "%A_ScriptFullPath%"
DetectHiddenWindows, On
WinGetTitle, MyTitle, ahk_id %A_ScriptHwnd%
WinGet, Script, List, %MyTitle%
Loop, %Script%
    If (A_ScriptHwnd <> ID := Script%A_Index%)
        WinClose, ahk_id %ID%
DetectHiddenWindows, Off

Run magnify.exe
WinWait Magnifier
WinActivate Magnifier

Sleep 222

Loop, 16
{
    Send {Enter}
    Sleep 11
}
Sleep 111


Send >#{+}
Sleep 111

Send >#{+}
Sleep 111

Send >#{+}
Sleep 111

Send >#{+}


Return
and seems to be working A-OK. So case closed...


...but as it is not pretty [with all those fast thus annoying changes happening on the screen] and anticipating its breakdown somewhere in the future [on the account of how precise amount of Sleep I might be needing to use on my next machine / system] and also wanting to save on-screen space, I would rather need to find a away to pin to my Taskbar a working executions of [already working] REG hack that I have [but in different versions]. And thus I created a new topic concerning this: viewtopic.php?f=22&t=115329
Last edited by A Keymaker on 03 Jul 2023, 11:04, edited 2 times in total.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Unable to send keys of Magnifier of Windows 10

Post by off » 22 Mar 2023, 20:15

After more testing, looks like the program cant accept keys sended too fast. So here it is

Code: Select all

Run magnify.exe
WinWait, ahk_class Screen Magnifier Window
SetKeyDelay, 150 ; this delay fit perfectly
Send, #{- 16} ; reset all zoom

Send, #{= 2}
; Send, #{+ 2}
Return
If you dont want resetting thingy, remove Line 4

edit: nvm, its only key delay, not + or =, both do zoom
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

Post Reply

Return to “Ask for Help (v1)”