Clicks to different resolutions

Ask gaming related questions (AHK v1.1 and older)
HR1-A
Posts: 2
Joined: 27 Jan 2024, 13:33

Clicks to different resolutions

Post by HR1-A » 28 Jan 2024, 15:04

Hello, I'm multi-boxing WoW on a private server and trying to send clicks to a monitor with a smaller resolution.
I would like to click on main monitor and send click to same place on alt monitor.
Main monitor: 2560x1440, alt monitor is 1920x1080
This code sends a click,just in the wrong spot.
Any help would be much appreciated after several days of trying different solutions and so far only getting this code to actually send a click.

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.

WinGet, WowID, List, World of Warcraft

#InstallMouseHook


~LButton::
    MouseGetPos, xpos, ypos
    WinActivate, Ahk_ID %WowID2%
    MouseClick, , %xpos%, %ypos%, , 0
    WinActivate, Ahk_ID %WowID1%
    MouseMove, %xpos%, %ypos%, 0
Return

Rohwedder
Posts: 7774
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Clicks to different resolutions

Post by Rohwedder » 30 Jan 2024, 02:55

Hallo,
try (untested):

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.
WinGet, WowID, List, World of Warcraft

#InstallMouseHook

~LButton::
    MouseGetPos, xpos, ypos
	ActiveMonitorSize(), W := Width, H := Height
    WinActivate, Ahk_ID %WowID2%
	ActiveMonitorSize()
    MouseClick, , xpos*Width/W, ypos*Height/H, , 0
    WinActivate, Ahk_ID %WowID1%
	ActiveMonitorSize()
    MouseMove, xpos*Width/W, ypos*Height/H, 0
Return

ActiveMonitorSize() { ; Monitor size of the active window
	Global Width, Height
	VarSetCapacity(I, 40), NumPut(40, I)
	DllCall("GetMonitorInfo", "Ptr", DllCall("MonitorFromWindow"
	, "Ptr", WinExist("A"), "UInt", 0x2), "Ptr", &I)
	Width := NumGet(I, 28, "Int") - NumGet(I, 20, "Int")
	Height := NumGet(I, 32, "Int") - NumGet(I, 24, "Int")
}

HR1-A
Posts: 2
Joined: 27 Jan 2024, 13:33

Re: Clicks to different resolutions

Post by HR1-A » 30 Jan 2024, 14:48

@ Rohwedder, I don't like to use the words Script God, but damn nice code,after slightly adjusting in game UI scale for second monitor
it clicks within 1 or 2 pixels on each monitor. Fantastic job and much appreciated. :bravo:

Post Reply

Return to “Gaming Help (v1)”