+ Post New Thread
Results 1 to 15 of 15
Scripts Thread, change resolution in Coding and Web Development; I'm trying to find an autoit script that I can compile for users to click to change their screen resolution ...
  1. #1
    chrbb's Avatar
    Join Date
    Oct 2005
    Location
    Midlands
    Posts
    1,508
    Thank Post
    141
    Thanked 67 Times in 62 Posts
    Rep Power
    47

    change resolution

    I'm trying to find an autoit script that I can compile for users to click to change their screen resolution to 800 x 600. We have just started using Abacus i planner which will only display full size at 800 x 600, which means that with our laptops it's actually quite difficult to read! Whilst most users are happy to change the resolution the standard way it would be easier to have a button to press

    Is it possible with autoit?

  2. #2

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    Quote Originally Posted by chrbb View Post
    I'm trying to find an autoit script that I can compile for users to click to change their screen resolution to 800 x 600. We have just started using Abacus i planner which will only display full size at 800 x 600, which means that with our laptops it's actually quite difficult to read! Whilst most users are happy to change the resolution the standard way it would be easier to have a button to press

    Is it possible with autoit?
    I have a batch file with a .exe to achieve this if your interested?

  3. #3
    DrPerceptron's Avatar
    Join Date
    Dec 2008
    Location
    In a house
    Posts
    930
    Thank Post
    34
    Thanked 135 Times in 115 Posts
    Rep Power
    41
    We use QRes to do this for the students who ask for it.

    SourceForge.net: QRes - Windows screen mode changer

  4. #4
    chrbb's Avatar
    Join Date
    Oct 2005
    Location
    Midlands
    Posts
    1,508
    Thank Post
    141
    Thanked 67 Times in 62 Posts
    Rep Power
    47
    Thanks, qres is my fallback, I was hoping to use autoit as I use that for the proxy on/off for the staff laptops so just wanted to have a consistant look.

  5. #5

    Join Date
    Feb 2006
    Location
    Derbyshire
    Posts
    1,381
    Thank Post
    181
    Thanked 211 Times in 171 Posts
    Rep Power
    65
    Dump qres in the \system32 folder on the machines and just use your AutoIT script to make a nice clicky button/gui to launch it with the right parameters?

  6. #6
    chrbb's Avatar
    Join Date
    Oct 2005
    Location
    Midlands
    Posts
    1,508
    Thank Post
    141
    Thanked 67 Times in 62 Posts
    Rep Power
    47
    I like that idea, not got enough brain cells to do it myself, can anyone lead me in the right way

  7. #7

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    9,240
    Thank Post
    1,058
    Thanked 1,068 Times in 625 Posts
    Rep Power
    740
    Use Vid res in a batch or call it:

    JD Design VidRes - Switch Video Resolution Utility

    EG:

    Code:
    vidres /H1024 /V768 /c4294967296

  8. #8

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,250
    Thank Post
    671
    Thanked 1,644 Times in 1,466 Posts
    Rep Power
    424
    Plus vidres can switch the resolution, run the program you need, then switch it back after.

    Ben

  9. #9

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,250
    Thank Post
    671
    Thanked 1,644 Times in 1,466 Posts
    Rep Power
    424
    * Set the resolution to 640x480 while running an application:

    vidres /H640 /V480 "/Xc:\path\appname.exe"

    when appname.exe closes, the display will switch back to its original settings.

    * Set the resolution to 640x480 only while the specified application is the active maximized window:

    vidres /H640 /V480 "/Xc:\path\appname.exe" /R

    If you close appname.exe, run it non-minimized, or switch to a different window, the original resolution is restored. If you switch back to appname.exe the resolution will switch back again.

  10. Thanks to plexer from:

    chrbb (5th December 2008)

  11. #10

    Join Date
    Dec 2008
    Posts
    197
    Thank Post
    7
    Thanked 32 Times in 18 Posts
    Rep Power
    18
    Download Resolution Packages (.zip) | Alt Link

    Notes:

    - QRes Packages for 800x600, 1024x768 and 1440x900;
    - Individual packages just needs to be allocated out by allocation software or AD (CC3/CC4 compatible).

  12. #11

    LeMarchand's Avatar
    Join Date
    Jan 2008
    Location
    The deepest pits of hell
    Posts
    2,198
    Thank Post
    303
    Thanked 339 Times in 241 Posts
    Rep Power
    143
    Does anyone know a way to get the resolution to automatically change dependant on whether an external monitor/projector is connected?

    I know that it's not much effort to make a couple of clicks, but these are teachers...

  13. #12


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,070
    Thank Post
    232
    Thanked 2,719 Times in 2,007 Posts
    Rep Power
    797

    Smile

    Here's how to do it using AutoIt. All you need to do is compile the script, create a shortcut to the EXE and than add the desired parameters to the end of the command-line. e.g. ChangeScreenRes.exe 1280 800 32 -1

    Code:
    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Compression=4
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ; Define variables
    $Width  = $CmdLine[1]
    $Height = $CmdLine[2]
    $BitsPerPixel = $CmdLine[3]
    $RefreshRate = $CmdLine[4]
    
    ; Change screen resolution
    _ChangeScreenRes($Width,$Height,$BitsPerPixel,$RefreshRate)
    
    ; Alternative method if you don't want to use command-line
    ;_ChangeScreenRes(1280,800,32,-1)
    
    ;===============================================================================
    ;
    ; Function Name:    _ChangeScreenRes()
    ; Description:      Changes the current screen geometry, colour and refresh rate.
    ; Version:          1.0.0.1
    ; Parameter(s):     $i_Width - Width of the desktop screen in pixels. (horizontal resolution)
    ;                   $i_Height - Height of the desktop screen in pixels. (vertical resolution)
    ;					$i_BitsPP - Depth of the desktop screen in bits per pixel.
    ;					$i_RefreshRate - Refresh rate of the desktop screen in hertz.
    ; Requirement(s):   AutoIt Beta > 3.1
    ; Return Value(s):  On Success - Screen is adjusted, @ERROR = 0
    ;                   On Failure - sets @ERROR = 1
    ; Forum(s):         http://www.autoitscript.com/forum/index.php?showtopic=20121
    ; Author(s):        Original code - psandu.ro
    ;                   Modifications - PartyPooper
    ;
    ;===============================================================================
    Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
    	Local Const $DM_PELSWIDTH = 0x00080000
    	Local Const $DM_PELSHEIGHT = 0x00100000
    	Local Const $DM_BITSPERPEL = 0x00040000
    	Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    	Local Const $CDS_TEST = 0x00000002
    	Local Const $CDS_UPDATEREGISTRY = 0x00000001
    	Local Const $DISP_CHANGE_RESTART = 1
    	Local Const $DISP_CHANGE_SUCCESSFUL = 0
    	Local Const $HWND_BROADCAST = 0xffff
    	Local Const $WM_DISPLAYCHANGE = 0x007E
    	If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting
    	If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting
    	If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting
    	If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting
    	Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    	Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
    	If @error Then
    		$B = 0
    		SetError(1)
    		Return $B
    	Else
    		$B = $B[0]
    	EndIf
    	If $B <> 0 Then
    		DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
    		DllStructSetData($DEVMODE, 4, $i_Width, 2)
    		DllStructSetData($DEVMODE, 4, $i_Height, 3)
    		DllStructSetData($DEVMODE, 4, $i_BitsPP, 1)
    		DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5)
    		$B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
    		If @error Then
    			$B = -1
    		Else
    			$B = $B[0]
    		EndIf
    		Select
    			Case $B = $DISP_CHANGE_RESTART
    				$DEVMODE = ""
    				Return 2
    			Case $B = $DISP_CHANGE_SUCCESSFUL
    				DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
    				DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
    						"int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)
    				$DEVMODE = ""
    				Return 1
    			Case Else
    				$DEVMODE = ""
    				SetError(1)
    				Return $B
    		EndSelect
    	EndIf
    EndFunc ;==>_ChangeScreenRes

  14. #13

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    Quote Originally Posted by Arthur View Post
    Here's how to do it using AutoIt. All you need to do is compile the script, create a shortcut to the EXE and than add the desired parameters to the end of the command-line. e.g. ChangeScreenRes.exe 1280 800 32 -1

    Code:
    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Compression=4
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ; Define variables
    $Width  = $CmdLine[1]
    $Height = $CmdLine[2]
    $BitsPerPixel = $CmdLine[3]
    $RefreshRate = $CmdLine[4]
    
    ; Change screen resolution
    _ChangeScreenRes($Width,$Height,$BitsPerPixel,$RefreshRate)
    
    ; Alternative method if you don't want to use command-line
    ;_ChangeScreenRes(1280,800,32,-1)
    
    ;===============================================================================
    ;
    ; Function Name:    _ChangeScreenRes()
    ; Description:      Changes the current screen geometry, colour and refresh rate.
    ; Version:          1.0.0.1
    ; Parameter(s):     $i_Width - Width of the desktop screen in pixels. (horizontal resolution)
    ;                   $i_Height - Height of the desktop screen in pixels. (vertical resolution)
    ;					$i_BitsPP - Depth of the desktop screen in bits per pixel.
    ;					$i_RefreshRate - Refresh rate of the desktop screen in hertz.
    ; Requirement(s):   AutoIt Beta > 3.1
    ; Return Value(s):  On Success - Screen is adjusted, @ERROR = 0
    ;                   On Failure - sets @ERROR = 1
    ; Forum(s):         http://www.autoitscript.com/forum/index.php?showtopic=20121
    ; Author(s):        Original code - psandu.ro
    ;                   Modifications - PartyPooper
    ;
    ;===============================================================================
    Func _ChangeScreenRes($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_BitsPP = @DesktopDepth, $i_RefreshRate = @DesktopRefresh)
    	Local Const $DM_PELSWIDTH = 0x00080000
    	Local Const $DM_PELSHEIGHT = 0x00100000
    	Local Const $DM_BITSPERPEL = 0x00040000
    	Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    	Local Const $CDS_TEST = 0x00000002
    	Local Const $CDS_UPDATEREGISTRY = 0x00000001
    	Local Const $DISP_CHANGE_RESTART = 1
    	Local Const $DISP_CHANGE_SUCCESSFUL = 0
    	Local Const $HWND_BROADCAST = 0xffff
    	Local Const $WM_DISPLAYCHANGE = 0x007E
    	If $i_Width = "" Or $i_Width = -1 Then $i_Width = @DesktopWidth ; default to current setting
    	If $i_Height = "" Or $i_Height = -1 Then $i_Height = @DesktopHeight ; default to current setting
    	If $i_BitsPP = "" Or $i_BitsPP = -1 Then $i_BitsPP = @DesktopDepth ; default to current setting
    	If $i_RefreshRate = "" Or $i_RefreshRate = -1 Then $i_RefreshRate = @DesktopRefresh ; default to current setting
    	Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    	Local $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
    	If @error Then
    		$B = 0
    		SetError(1)
    		Return $B
    	Else
    		$B = $B[0]
    	EndIf
    	If $B <> 0 Then
    		DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
    		DllStructSetData($DEVMODE, 4, $i_Width, 2)
    		DllStructSetData($DEVMODE, 4, $i_Height, 3)
    		DllStructSetData($DEVMODE, 4, $i_BitsPP, 1)
    		DllStructSetData($DEVMODE, 4, $i_RefreshRate, 5)
    		$B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
    		If @error Then
    			$B = -1
    		Else
    			$B = $B[0]
    		EndIf
    		Select
    			Case $B = $DISP_CHANGE_RESTART
    				$DEVMODE = ""
    				Return 2
    			Case $B = $DISP_CHANGE_SUCCESSFUL
    				DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
    				DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
    						"int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width)
    				$DEVMODE = ""
    				Return 1
    			Case Else
    				$DEVMODE = ""
    				SetError(1)
    				Return $B
    		EndSelect
    	EndIf
    EndFunc ;==>_ChangeScreenRes

    Isnt it abit of a long way round when you can do it with one line in a batch file?

  15. #14


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,070
    Thank Post
    232
    Thanked 2,719 Times in 2,007 Posts
    Rep Power
    797
    The main reason I like using AutoIt is that you don't have to rely on external programs if you know how to do everything within your script. Also if you are already using AutoIt to create a script to do another task it makes sense to use AutoIt (rather than a batch file) to change the resolution too.

  16. #15

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    Quote Originally Posted by Arthur View Post
    The main reason I like using AutoIt is that you don't have to rely on external programs if you know how to do everything within your script. Also if you are already using AutoIt to create a script to do another task it makes sense to use AutoIt (rather than a batch file) to change the resolution too.
    Good point.

    I would have thought you could do this in group policy by now though.

SHARE:
+ Post New Thread

Similar Threads

  1. projectors and resolution
    By chrbb in forum Hardware
    Replies: 15
    Last Post: 14th April 2013, 12:39 PM
  2. Change resolution an all CC3 stations?
    By reggiep in forum Network and Classroom Management
    Replies: 8
    Last Post: 14th July 2008, 11:36 AM
  3. change user desktop screen resolution
    By PEO in forum Windows
    Replies: 9
    Last Post: 18th June 2008, 12:16 PM
  4. Screen Resolution
    By plock in forum Windows
    Replies: 6
    Last Post: 17th December 2007, 02:56 PM
  5. Replies: 2
    Last Post: 14th December 2007, 10:33 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •