Thanks to threads here dealing with setting monitor resolution via AHK, I now have my triple display setup switching between modes (Analog, Digital, TV) perfectly, with one exception: When switching to dual monitor mode the secondary monitor always defaults to being on the right side of the primary monitor (as shown in 'Display Properties'>'Settings') instead of the left, which is how the monitors are physically arranged.
So how does one programmatically "move" the secondary monitor relative to the primary? Although one might be able to use AHK's Recorder to drag the monitor icons around, there's got to be a cleaner way of accomplishing this task. Ideas please!
Programmatically move monitor position
Started by
jaysee
, Apr 20 2008 10:30 PM
2 replies to this topic
#1
-
Posted 20 April 2008 - 10:30 PM
Assuming you are using something similar if not the same as below, I believe its a case of changing the number in red to either a plus or minus according to the resolution of each monitor.
In the case of moving to the left, I suggest trying minus whatever the resolution is of your secondary monitor, if that doesnt work try adding one ie 1024 or 1025...
In the case of moving to the left, I suggest trying minus whatever the resolution is of your secondary monitor, if that doesnt work try adding one ie 1024 or 1025...
; Enables, disables or toggles a display device. ; ; DeviceName: The name of the device, e.g. \\.\DISPLAY1 ; Alternatively, it can be the index of the device, which might ; not be the same as the number shown in Display Settings. ; Action: The action to take. ; 0 Disable (false is synonymous with 0) ; 1 Enable (true is synonymous with 1) ; -1 Toggle ; NoReset: If true, settings will be saved to the registry, but not applied. ; ; The following can be used to apply settings saved in the registry: ; DllCall("ChangeDisplaySettings", "uint", 0, "uint", 1) ; ; Return values: ; DISP_CHANGE_SUCCESSFUL 0 ; DISP_CHANGE_RESTART 1 ; DISP_CHANGE_FAILED -1 ; DISP_CHANGE_BADMODE -2 ; DISP_CHANGE_NOTUPDATED -3 ; DISP_CHANGE_BADFLAGS -4 ; DISP_CHANGE_BADPARAM -5 ; EnableDisplayDevice(DeviceName, Action=1, NoReset=false) { if (Action = -1) || (DeviceName+0 != "") { VarSetCapacity(DisplayDevice, 424), NumPut(424, DisplayDevice, 0) VarSetCapacity(ThisDeviceName, 32, 0) Index = 0 Loop { if !DllCall("EnumDisplayDevices", "UInt", 0, "UInt", A_Index-1, "UInt", &DisplayDevice, "UInt", 0) return -5 ThisDeviceState := NumGet(DisplayDevice, 164) Index += 1 DllCall("lstrcpynA", "Str", ThisDeviceName, "UInt", &DisplayDevice+4, "int", 32) if (DeviceName = Index || DeviceName = ThisDeviceName) { if Action = -1 Action := !(ThisDeviceState & 1) DeviceName := ThisDeviceName break } } } VarSetCapacity(devmode, 156, 0), NumPut(156, devmode, 36, "UShort") if (Action){ NumPut(0x000020, devmode, 40) ; Enable by setting position = {0,0} VarSetCapacity(Point,8,0) Numput(-[color=red]1024[/color],Point) Numput(&point,devmode,44) } else NumPut(0x180020, devmode, 40) ; Disable by setting size = {0,0} err := DllCall("ChangeDisplaySettingsEx", "str", DeviceName, "uint", &devmode, "uint", 0, "uint", 0x10000001, "uint", 0) if !err && !NoReset err := DllCall("ChangeDisplaySettings", "uint", 0, "uint", 1) return err, ErrorLevel:=Action }
#2
-
Posted 20 April 2008 - 10:43 PM
Superfraggle:
Thanks for pointing me in the right direction. No, I hadn't seen the script you referenced but reviewing it sent me off researching more about API calls; I'm experiencing a bit of a steep learning curve right now...
Thanks for pointing me in the right direction. No, I hadn't seen the script you referenced but reviewing it sent me off researching more about API calls; I'm experiencing a bit of a steep learning curve right now...
#3
-
Posted 21 April 2008 - 09:35 PM