Hi.
I'm converting a script from v1.1.36.02 to v2.0-rc.2 and I'm experiencing inconsistent results when I try to determine the primary monitor.
This is my system's (Windows 10 21H2) current configuration (monitor 1, the one on the right, is the primary monitor):
This v1 code:
Code: Select all
SysGet, primaryMonitorNumber, MonitorPrimary
SysGet, primaryMonitorCoords, Monitor, %primaryMonitorNumber%
SysGet, primaryMonitorName, MonitorName , %primaryMonitorNumber%
MsgBox, Name: %primaryMonitorName%`nNumber: %primaryMonitorNumber%`nLeft: %primaryMonitorCoordsLeft%`nTop: %primaryMonitorCoordsTop%`nRight: %primaryMonitorCoordsRight%`nBottom: %primaryMonitorCoordsBottom%
But this v2 code:---------------------------
primary mon v1.ahk
---------------------------
Name: \\.\DISPLAY1
Number: 1
Left: 0
Top: 0
Right: 1920
Bottom: 1200
Code: Select all
primaryMonitorNumber:=MonitorGetPrimary()
MonitorGet primaryMonitorNumber, &primaryMonitorCoordsLeft, &primaryMonitorCoordsTop, &primaryMonitorCoordsRight, &primaryMonitorCoordsBottom
primaryMonitorName:=MonitorGetName(primaryMonitorNumber)
MsgBox ("Name:" . primaryMonitorName . "`n" . "Number: " . primaryMonitorNumber . "`n" . "Left: " . primaryMonitorCoordsLeft . "`n" . "Top: " . primaryMonitorCoordsTop . "`n" . "Right: " . primaryMonitorCoordsRight . "`n" . "Bottom: " . primaryMonitorCoordsBottom)
---------------------------
primary mon v2.ahk
---------------------------
Name:\\.\DISPLAY2
Number: 2
Left: -1920
Top: 0
Right: 0
Bottom: 1200
If I understand this previous thread correctly, it was concluded there that there was a known discrepancy between the monitor number displayed in Settings and the one that's returned by MonitorGetPrimary() function. But, shouldn't this number, whichever it is, when feeded to MonitorGet, produce the coordinates of the primary monitor (as is the case in v1)?
BTW, if I omit N in MonitorGet and MonitorGetName():
Code: Select all
primaryMonitorNumber:=MonitorGet( , &primaryMonitorCoordsLeft, &primaryMonitorCoordsTop, &primaryMonitorCoordsRight, &primaryMonitorCoordsBottom)
primaryMonitorName:=MonitorGetName()
MsgBox ("Name:" . primaryMonitorName . "`n" . "Number: " . primaryMonitorNumber . "`n" . "Left: " . primaryMonitorCoordsLeft . "`n" . "Top: " . primaryMonitorCoordsTop . "`n" . "Right: " . primaryMonitorCoordsRight . "`n" . "Bottom: " . primaryMonitorCoordsBottom)
which are the correct coordinates and consistent with v1. This also shows a discrepancy between the number of the primary monitor returned by MonitorGet() with N omitted and the one returned by MonitorGetPrimary() (in other words, shouldn't MonitorGetPrimary() and MonitorGet(<no parameters>) yield the same number?).---------------------------
primary mon v2.ahk
---------------------------
Name:\\.\DISPLAY1
Number: 1
Left: 0
Top: 0
Right: 1920
Bottom: 1200
---------------------------
OK
---------------------------
So, is this a bug in MonitorGetPrimary() or am I doing something wrong?
Thank you.