Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

Get help with using AutoHotkey and its commands and hotkeys
FlyingFree
Posts: 10
Joined: 24 Apr 2018, 01:52

Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

13 Apr 2020, 23:49

MouseClickDrag works fine on Windows 7 with 2 monitors and DisplayFusion if it is only using monitor 1, but fails 10% of the time if it is run on monitor 2, mistakenly sending the mouse to the proper coords but on monitor 1 not 2.

[Moderator's note: Topic moved from Bug Reports.]
joefiesta
Posts: 377
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

14 Apr 2020, 08:43

1. what is DisplayFusion?

2. what is the code you run?

3. Bugs that are not reliably and easily reproducible are VERY difficult to understand or fix. And, if it only occurs when using DisplayFusion--whatever that is--then it is probably not AHK.
FlyingFree
Posts: 10
Joined: 24 Apr 2018, 01:52

Re: Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

14 Apr 2020, 08:55

DisplayFusion is software for managing multiple displays in Windows since Windows is so crap at it. I run a macro for opening Hearthstone packs, if I have the Hearthstone window on monitor 1 it works fine, if i have it on monitor 2 the mouse goes over to monitor 1 about 10% of the time. I don't know if DisplayFusion has any impact on this I just mentioned it since it's part of my environment.

This is my code:

Code: Select all

InputBox, UserInput, Number of Packs, (Hearthstone resolution must be set to 1024x768 - F7 to quit), , 385, 125, , , , , 0
if ErrorLevel or UserInput = 0
    ExitApp
else
    numberoftimes := UserInput

i := 0

Loop
{
	If WinNotExist Hearthstone
	{
		MsgBox,, Error, Hearthstone not detected
		ExitApp
	}
	WinActivate Hearthstone
	WinWait Hearthstone
	BlockInput Mouse
	i++
	sleep 2000
	MouseClickDrag, L, 100, 350, 615, 360, 20
	sleep 5000
	MouseClick, L , 410, 255,, 5
	sleep 50
	MouseClick, L , 635, 170,, 5
	sleep 50
	MouseClick, L , 840, 265,, 5
	sleep 50
	MouseClick, L , 740, 580,, 5
	sleep 50
	MouseClick, L , 465, 565,, 5
	sleep 2000
	MouseClick, L , 635, 430,, 5
} until i = numberoftimes
ExitApp

F7:: ; stop macro
    ExitApp
return
Industry
Posts: 10
Joined: 26 Apr 2017, 14:50

Re: Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

26 Apr 2020, 17:04

Not related to the specific issue that you're having, but I noticed that when running DisplayFusion and pressing Alt + Tab, the alt button stays depressed, causing all sorts of issues in my script. https://www.autohotkey.com/boards/viewtopic.php?f=76&t=74927&p=325156
DisplayFusion does not play nice with AHK or Windows in General. I disabled it entirely but you might want to contact the maker for them to release a fix for the issue you're having.
lexikos
Posts: 6879
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Mouse operations intermitently use wrong monitor on multimonitor Windows 7 computer

03 May 2020, 21:10

I think there is distinction between monitors only when you specifically request information relating to monitors, such as with SysGet. All of the mouse and window commands work with simple two-dimensional coordinate space (both internally and with regard to their parameters), where objects on the secondary monitor are simply offset by some amount, depending on how you've placed your monitors (virtually, within the display settings, not physically).

MouseClick(Drag) uses coordinates relative to the active window by default. If it is clicking in the wrong location, that is because you are giving it the wrong coordinates, or it is using an unexpected point of reference - in other words, it is very likely that your problem is due to some external force changing the active window. If you cannot prevent the active window from changing, you can retrieve the window's position and use it explicitly in your script (e.g. x+100 instead of 100).

However, there are some known limitations regarding DPI scaling, where system APIs scale coordinates in ways AutoHotkey isn't designed to expect, based on which window the API is dealing with and what its scaling factor and DPI awareness are. For instance, see MouseMove using wrong coordinates (Monitor dependent).

By the way, this is invalid (the first space should be removed):

Code: Select all

If WinNotExist Hearthstone
As is, it is treated as If (emptyVar . alsoEmpty).

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], JackMa, Thorx and 295 guests