Toggle Magnifier

Post your working scripts, libraries and tools for AHK v1.1 and older
SundayProgrammer
Posts: 143
Joined: 25 Dec 2020, 12:26

Toggle Magnifier

Post by SundayProgrammer » 06 Jan 2022, 00:28

don't like to have two hotkeys for opening/closing magnifier, hence attempted to write a toggle. and turned out it needs a trick to work. so this may save you some time from struggling if you also want such a toggle one day.

Code: Select all

Capslock::Gosub, ToggleMagnifier

ToggleMagnifier:
	IfWinActive, ahk_exe Magnify.exe
		Gui, Show,, Magnifier Dummy Prompt
	IfWinExist, ahk_exe Magnify.exe
	{	Send, #{Esc}
		IfWinExist, Magnifier Dummy Prompt
			WinClose
	}Else Run, Magnify
	Return

User avatar
TheDewd
Posts: 1508
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Toggle Magnifier

Post by TheDewd » 19 Jan 2022, 10:58

The following works for me on Windows 10:

Code: Select all

#SingleInstance, Force

Capslock::
	Process, Exist, Magnify.exe
	
	If (ErrorLevel) {
		Send, #{Esc}
	} Else {
		Run, Magnify.exe
	}
return

SundayProgrammer
Posts: 143
Joined: 25 Dec 2020, 12:26

Re: Toggle Magnifier

Post by SundayProgrammer » 19 Jan 2022, 11:31

TheDewd wrote:
19 Jan 2022, 10:58
The following works for me on Windows 10:

Code: Select all

#SingleInstance, Force

Capslock::
	Process, Exist, Magnify.exe
	
	If (ErrorLevel) {
		Send, #{Esc}
	} Else {
		Run, Magnify.exe
	}
return
try this scenario: 1, set the magnifier to lens view; 2, switch on the magnifier; 3, touch (touchscreen assumed) somewhere outside the lens; 4, use your finger to move the lens by its handle (now, the lens itself becomes an active window); 5, try your toggle now, it's no longer working.

User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Toggle Magnifier

Post by SKAN » 19 Jan 2022, 20:39

@SundayProgrammer

Thanks. I didn't know about #Esc key.
I will be using it like follows:
( i.e, equivalent code in V2)

Code: Select all

#NoEnv
#Warn
#SingleInstance, Force

#IfWinExist ahk_class MagUIClass
#NumPadMult:: Send, #{Esc}
#IfWinExist

SundayProgrammer
Posts: 143
Joined: 25 Dec 2020, 12:26

Re: Toggle Magnifier

Post by SundayProgrammer » 19 Jan 2022, 23:09

SKAN wrote:
19 Jan 2022, 20:39
@SundayProgrammer

Thanks. I didn't know about #Esc key.
thanks, @SKAN. i'm glad to learn that my post did help others, in whichever way it doesn't matter. and even just a bit. i gained a lot from this forum/community.

User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: Toggle Magnifier

Post by SKAN » 19 Jan 2022, 23:44

SundayProgrammer wrote:
19 Jan 2022, 23:09
in whichever way it doesn't matter. and even just a bit.
Just a bit?. This is huge for me.

I was just using default OS hotkeys:
#NumpadAdd starts magnifier and also zooms...
#NumpadSub unzooms...
But I never knew how to close it. WinClose() wouldn't do it.
All the Time I was clicking the close button to close magnifier.

Finally, a solution. :thumbup:

However there is a unfortunate limitation in Windows 7.
#NumpadAdd starts magnifier and also zooms...
But I have to release the win key before I can use win+NumpadMult.

In Win 10 & 11, I can just place the mouse cursor at point of interest and Open, zoom/unzoom, close without releasing the Windows key.

Post Reply

Return to “Scripts and Functions (v1)”