How can I retrieve Windows Monitor Layout Numbers?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
grosner
Posts: 10
Joined: 11 Sep 2016, 13:08

How can I retrieve Windows Monitor Layout Numbers?

Post by grosner » 17 Oct 2022, 17:10

How can I obtain the exact same numeric numbers that show when clicking the identify button in Windows->System-Display?

For example, with several 4K monitors:
  • If windows shows the left most monitor as Display 3, then I want AHK to return X = -3840 for monitor 3.
  • Sysget monitor command appears to return monitor coordinates in no particular order.
  • After a reboot, Sysget could return the monitors coordinate sets in a different order
Additional Info:
  • The actual monitor numbers showing in the Windows Control panel may change (on their own) after a reboot.
  • So, in a four monitor configuration, Windows may show Displays 3,4,1,2 or 3,1,2,4 or 2,4,1,3 or (if we are lucky) 1,2,3,4.
  • Rarely do I see the color management identify monitor results match the Windows Monitor numbers.
  • SysGet monitor subcommands seems to match the same values as shown in the color management values
Again, I simply want to use a function to return the Windows Monitor number as shown in Windows System-Display settings.

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

Re: How can I retrieve Windows Monitor Layout Numbers?

Post by Rohwedder » 18 Oct 2022, 02:38

Hallo,
I only own 2 monitors. For these, the monitor numbers shown in this script always match the display in the Windows system display settings:

Code: Select all

#Persistent
SysGet, Mo, 80 ;Number of monitors
Loop,% Mo
	SysGet, Mo%A_Index%, MonitorWorkArea, %A_Index%
CoordMode, Mouse, Screen ;Mouse coordinates relative to the screen
SetTimer, Monitors, 1000
Monitors:
MouseGetPos, MX, MY
Loop,% Mo
{
	Left := Mo%A_Index%Left, Right := Mo%A_Index%Right
	Top:= Mo%A_Index%Top, Bottom := Mo%A_Index%Bottom
	IF MX between %Left% and %Right%
		IF MY between %Top% and %Bottom%
			ToolTip,% "Monitor: " A_Index
}
Return
Is this different with your monitors?

grosner
Posts: 10
Joined: 11 Sep 2016, 13:08

Re: How can I retrieve Windows Monitor Layout Numbers?

Post by grosner » 18 Oct 2022, 07:23

In windows system display control panel, repositioning monitor two on left shows monitors in 2,1 order and then values do not match Sysget.

Post Reply

Return to “Ask for Help (v1)”