I have a two monitor setup on an XP machine. I would like to be able to go to display\settings and move the relative positions of the monitors. When I use Autoscriptwriter, it does not record the movements I make. The relative positions remain unchanged.
Any ideas of how to do this? :?
Move second monitor position
Started by
davidcj
, Feb 21 2009 01:21 AM
6 replies to this topic
#1
-
Posted 21 February 2009 - 01:21 AM
DisplayPosition_Set(device_name, x, y, defer=false) { ; Prepare the DEVMODE structure. VarSetCapacity(devmode, 158, 0), NumPut(158, devmode, 0, "ushort") ; Get current display settings. -1=current, -2=registry DllCall("EnumDisplaySettings","str",device_name,"int",-1,"uint",&devmode) if ! NumGet(devmode, 108) ; dmPelsWidth (=0 means display is disabled) DllCall("EnumDisplaySettings","str",device_name,"int",-2,"uint",&devmode) ; dmFlags |= DM_POSITION NumPut(NumGet(devmode,40)|0x20, devmode, 40) ; dmPosition.X := x, dmPosition.Y := y NumPut(x,devmode,44,"int"), NumPut(y,devmode,48,"int") err := DllCall("ChangeDisplaySettingsEx","str",device_name,"uint",&devmode,"uint",0,"uint",0x10000001,"uint",0) ; ChangeDisplaySettings() is called here for two reasons: ; - A restart is otherwise required to enable a secondary display device. ; See: http://support.microsoft.com/kb/308216 ; - Disabling display devices with just ChangeDisplaySettingsEx() ; tends to leave them turned on. if (!err && !defer) err := DllCall("ChangeDisplaySettings", "uint", 0, "uint", 1) return err }Your second display is probably "\\.\DISPLAY2", but on my system 1 and 2 seem to swap around randomly when I enable/disable displays. :? Might be a Windows 7 quirk...
For example, if display 2 is 1680x1050, the following puts it to the left of the primary and 100 pixels up.
DisplayPosition_Set("\\.\DISPLAY2", -1680, -100)I originally used this to simultaneously enable and position a display.
#2
-
Posted 21 February 2009 - 02:09 AM
I get this error when I try to use the script:
"Error: Call to nonexistent function.
Specifically: StdOut(NumGet(devmode, 108),"width")"
...
"---> 024: if ! StdOut(NumGet(devmode, 108),"width")
025: DllCall("EnumDisplaySettings","str",device_name,"int",-2,"uint",&devmode) "
"Error: Call to nonexistent function.
Specifically: StdOut(NumGet(devmode, 108),"width")"
...
"---> 024: if ! StdOut(NumGet(devmode, 108),"width")
025: DllCall("EnumDisplaySettings","str",device_name,"int",-2,"uint",&devmode) "
#3
-
Posted 19 June 2009 - 10:11 AM
Sorry, I left some debug code in. Just remove the bits in red:
if ! [color=red]StdOut([/color]NumGet(devmode, 108)[color=red],"width")[/color]
#4
-
Posted 19 June 2009 - 10:15 AM
Lexikos,
Where can I find information on what DllCalls I need to change certain OS settings?
What other programming languages do I have to be able to write AHK scripts such as this one.
For example, which dll and which function do I have to call to change the behaviour of a particular systray icon? (always hide, hide when inactive, always visible)
Where can I find information on what DllCalls I need to change certain OS settings?
What other programming languages do I have to be able to write AHK scripts such as this one.
For example, which dll and which function do I have to call to change the behaviour of a particular systray icon? (always hide, hide when inactive, always visible)
#6
-
Posted 19 June 2009 - 04:42 PM
For example, which dll and which function do I have to call to change the behaviour of a particular systray icon? (always hide, hide when inactive, always visible)
You can learn all yourself, like I do since I know and love AHK
MSDN and Google is where you get all info you need.
Example: [Lib] TrayIcon_...()
#7
-
Posted 19 June 2009 - 07:03 PM