Open/close magnifier Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wolfhound
Posts: 4
Joined: 11 Feb 2021, 07:59

Open/close magnifier

Post by wolfhound » 08 Aug 2022, 19:17

I know nothing about writing AHK scripts, i have a couple but i only got them by getting people in here to write them for me. Ok... can someone please just copy and paste this exactly as it is but simply with the right mouse button changed to whatever needs to be there so when i click on it it opens the magnifyer and also with the left mouse button with whatever needs to be there to close the magnifyer? Thanks.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
RButton::Send #+s

MButton::
ExitApp
Return
Last edited by BoBo on 08 Aug 2022, 23:26, edited 1 time in total.
Reason: Changed subject line from "Can someone please help me with something?" to "Open/close magnifier" to be more specific.

User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Can someone please help me with something?  Topic is solved

Post by mikeyww » 08 Aug 2022, 19:39

Code: Select all

If !Instr(A_AhkPath, "UIA") && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
 SplitPath, A_AhkPath, fn ; https://www.autohotkey.com/docs/Program.htm#Installer_uiAccess
 ahk = %ProgramFiles%\AutoHotkey\AutoHotkeyU64_UIA.exe
 ; ahk := StrReplace(A_AhkPath, fn, "AutoHotkeyU64_UIA.exe")
 Try Run "%ahk%" /restart "%A_ScriptFullPath%"
 ExitApp
}
RButton::Run, magnify

#IfWinExist ahk_exe magnify.exe
LButton::
WinClose
SoundBeep, 1200
Return
#IfWinExist

MButton::
SoundBeep, 1000
ExitApp
Suggestion: for your next thread subject (and preferably this one, too), summarize the problem instead of your interest in getting help to solve it.

wolfhound
Posts: 4
Joined: 11 Feb 2021, 07:59

Re: Can someone please help me with something?

Post by wolfhound » 09 Aug 2022, 16:35

mikeyww wrote:
08 Aug 2022, 19:39

Code: Select all

If !Instr(A_AhkPath, "UIA") && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
 SplitPath, A_AhkPath, fn ; https://www.autohotkey.com/docs/Program.htm#Installer_uiAccess
 ahk = %ProgramFiles%\AutoHotkey\AutoHotkeyU64_UIA.exe
 ; ahk := StrReplace(A_AhkPath, fn, "AutoHotkeyU64_UIA.exe")
 Try Run "%ahk%" /restart "%A_ScriptFullPath%"
 ExitApp
}
RButton::Run, magnify

#IfWinExist ahk_exe magnify.exe
LButton::
WinClose
SoundBeep, 1200
Return
#IfWinExist

MButton::
SoundBeep, 1000
ExitApp
Suggestion: for your next thread subject (and preferably this one, too), summarize the problem instead of your interest in getting help to solve it.
Thanks for replying. Why i wanted that is because i'm currently playing a Steam game that requires me to use the map often and, so typical of indie developers, they made the map small as hell and no way to zoom in... which is especially annoying for me as i'm also slightly vision-impaired. I just tried your script there and if i use exactly what you wrote there from top to bottom then nothing actually happens when i double click on the AHK script file (like AHK doesn't even open and i'm just testing on my desktop, not even in-game)

However if i simply copy from "RButton::Run, magnify" down and keep what i had at the top in my original post then it opens the magnifyer but i can't then close AHK by pressing the middle mouse button, leaving me with no choice but to turn the power off and back on. If i then remove "SoundBeep, 1000" from what you put as the final instruction and just have it like i had it in my original post then i can close AHK... however nothing i try can get the left mouse button working so i can't zoom back out once i'm done. Do you know what's not working properly... or possibly even know a different method for zooming in and out in a PC game that doesn't have the borderless window option?

User avatar
mikeyww
Posts: 26939
Joined: 09 Sep 2014, 18:38

Re: Open/close magnifier

Post by mikeyww » 09 Aug 2022, 17:50

Yes. You need to use the UIA, which is described at the URL that is posted in the script. The script might have the wrong path to that program, so you can check to see where the program is on your computer. Another way to run with UI access is described at the URL.

Post Reply

Return to “Ask for Help (v1)”