novi Posted December 20, 2005 Share Posted December 20, 2005 hi everyone. can anybody tell me how can i change de screen resolution from a script, please help me soon. thanks pd: Excuse my english please [COLOR=green] Link to comment Share on other sites More sharing options...
erebus Posted December 21, 2005 Share Posted December 21, 2005 Check this:http://www.autoitscript.com/forum/index.php?showtopic=13517Please use the search forum function in the future. Link to comment Share on other sites More sharing options...
SandelPerieanu Posted December 21, 2005 Share Posted December 21, 2005 Try this! DisplayChangeRes(1024, 768, 32, 85) Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ) $DM_PELSWIDTH = 0x00080000 $DM_PELSHEIGHT = 0x00100000 $DM_BITSPERPEL = 0x00040000 $DM_DISPLAYFREQUENCY = 0x00400000 $CDS_TEST = 0x00000002 $CDS_UPDATEREGISTRY = 0x00000001 $DISP_CHANGE_RESTART = 1 $DISP_CHANGE_SUCCESSFUL = 0 $HWND_BROADCAST = 0xffff $WM_DISPLAYCHANGE = 0x007E $DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]") $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE)) If @error Then $B = 0 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, $WIDTH, 2) DllStructSetData ($DEVMODE, 4, $HEIGHT, 3) DllStructSetData ($DEVMODE, 4, $BPP, 1) DllStructSetData ($DEVMODE, 4, $FREQ, 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", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" Return $B EndSelect EndIf EndFunc ;==>DisplayChangeRes Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 10, 2006 Share Posted January 10, 2006 (edited) Try this! CODE DisplayChangeRes(1024, 768, 32, 85) Func DisplayChangeRes($WIDTH, $HEIGHT, $BPP, $FREQ) $DM_PELSWIDTH = 0x00080000 $DM_PELSHEIGHT = 0x00100000 $DM_BITSPERPEL = 0x00040000 $DM_DISPLAYFREQUENCY = 0x00400000 $CDS_TEST = 0x00000002 $CDS_UPDATEREGISTRY = 0x00000001 $DISP_CHANGE_RESTART = 1 $DISP_CHANGE_SUCCESSFUL = 0 $HWND_BROADCAST = 0xffff $WM_DISPLAYCHANGE = 0x007E $DEVMODE = DLLStructCreate ("byte[32];int[10];byte[32];int[6]") $B = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DLLStructGetPtr ($DEVMODE)) If @error Then $B = 0 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, $WIDTH, 2) DllStructSetData ($DEVMODE, 4, $HEIGHT, 3) DllStructSetData ($DEVMODE, 4, $BPP, 1) DllStructSetData ($DEVMODE, 4, $FREQ, 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", $BPP, "int", $HEIGHT * 2 ^ 16 + $WIDTH) $DEVMODE = "" Return 1 Case Else $DEVMODE = "" Return $B EndSelect EndIf EndFunc ;==>DisplayChangeRes Oh, the brain pain! I am in need of a script to change screen resolution myself. I don't want to add any executables to the target server under load if at all possible, so I would prefer to accomplish it from a compiled AutoIT script that did not call anything outside that isn't native to the Windows (2000 and 2003) load. This script didn't look right when I read it, because it calls dll functions that are not in AutoIT. I pasted it into SciTE and it failes checks and won't compile, as expected. Where do the DLLStructCreate(), and DllStructSetData() functions come from? Is there an #include file with these functions? Are they calls to VBScript or something outside of AutoIT? Edited January 10, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
SandelPerieanu Posted January 10, 2006 Share Posted January 10, 2006 Oh, the brain pain! I am in need of a script to change screen resolution myself. I don't want to add any executables to the target server under load if at all possible, so I would prefer to accomplish it from a compiled AutoIT script that did not call anything outside that isn't native to the Windows (2000 and 2003) load.This script didn't look right when I read it, because it calls dll functions that are not in AutoIT. I pasted it into SciTE and it failes checks and won't compile, as expected. Where do the DLLStructCreate(), and DllStructSetData() functions come from? Is there an #include file with these functions? Are they calls to VBScript or something outside of AutoIT? hey man!!!! try http://www.autoitscript.com/autoit3/files/...-beta-Setup.exeand work! Link to comment Share on other sites More sharing options...
PartyPooper Posted January 11, 2006 Share Posted January 11, 2006 Works for me. Good script psandu.ro Be handy to have as a UDF in the standard library. Are you going to submit it? Link to comment Share on other sites More sharing options...
SandelPerieanu Posted January 11, 2006 Share Posted January 11, 2006 Works for me. Good script psandu.ro Be handy to have as a UDF in the standard library. Are you going to submit it? I don't know how. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 11, 2006 Moderators Share Posted January 11, 2006 I don't know how.To make it a UDF or submit it? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
SandelPerieanu Posted January 11, 2006 Share Posted January 11, 2006 To make it a UDF or submit it? whatever! Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 11, 2006 Share Posted January 11, 2006 hey man!!!! try http://www.autoitscript.com/autoit3/files/...-beta-Setup.exeand work! That did it! I hereby proclaim that it shalt be known throughout this land that PSANDO.RO is an AutoIT steely-eyed missile man, and that he doth rocketh! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
sheck Posted January 13, 2006 Share Posted January 13, 2006 This works great. Excelent job, psandu.ro Too bad there is no way to use just AutoIt, without DLL calls to change res. Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
ItsMillertime4u Posted April 13, 2006 Share Posted April 13, 2006 When I try to run this my script gets hung at: Case $B = $DISP_CHANGE_SUCCESSFUL DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_UPDATEREGISTRY on a WinXP SP2 running v3.1.1.117 .......it does change the display settings, but it get hung at that point when it tries to do the DllCall and so the script never finishes. Does anyone know what would cause this, or a way inwhich I could set a timeout within the script so that it automatically quits after something like five seconds. One other thing does anyone if there is a beta for v3.1.1.117 AutoItX..., I was thinking about rewriting this UDF in AutoItX, but the version I have v3.1 from Aug 2005 does included support for DllStructSetData, DLLStructCreate, etc Link to comment Share on other sites More sharing options...
Uten Posted April 14, 2006 Share Posted April 14, 2006 One other thing does anyone if there is a beta for v3.1.1.117 AutoItX..., I was thinking about rewriting this UDF in AutoItX, but the version I have v3.1 from Aug 2005 does included support for DllStructSetData, DLLStructCreate, etcUhh, what do you intend to do? Take a look at this and rethink Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
ItsMillertime4u Posted April 14, 2006 Share Posted April 14, 2006 That's simple stuff, I'm trying to some advanced things that vbscript can't natively do like Api Calls. Also I forgot to mention that I am running this as an regular user account.......which may be part of the problem.... But the way I look at it I probably could comment out that part of the code, since the display settings are changed anyways. From what I can tell that part of the code just tells you if the change was successful or not and wether or not you have to reboot, and since the code: $B = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DLLStructGetPtr ($DEVMODE), "int", $CDS_TEST) is working Link to comment Share on other sites More sharing options...
Bert Posted April 14, 2006 Share Posted April 14, 2006 Check this post: http://www.autoitscript.com/forum/index.ph...ndpost&p=170032It is a solution that may do what you need without reinventing the wheel. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
tamahome Posted April 20, 2009 Share Posted April 20, 2009 (edited) expandcollapse popup; Here's how I did it: $res = "1600 by 1024 pixels" run("control desk.cpl") winwait("Display Properties") for $i = 1 to 4 controlcommand("Display Properties", "", "SysTabControl321", "TabRight") next winwait("Display Properties", "Settings") $controltext = controlgettext("Display Properties", "Settings", "Static8") while $controltext <> $res controlsend("Display Properties", "", "msctls_trackbar321", "{RIGHT}") $lastcontroltext = $controltext $controltext = controlgettext("Display Properties", "Settings", "Static8") if $lastcontroltext = $controltext then exitloop wend while $controltext <> $res ; try moving left controlsend("Display Properties", "", "msctls_trackbar321", "{LEFT}") $lastcontroltext = $controltext $controltext = controlgettext("Display Properties", "Settings", "Static8") if $lastcontroltext = $controltext then exitloop wend if $controltext <> $res then ; msgbox(4096, "bad", "bad", 5) exit(1) else ; msgbox(4096, "good", "good", 5) endif controlclick("Display Properties", "", "OK") winwait("Monitor Settings", "") controlclick("Monitor Settings", "", "&Yes") Edited April 20, 2009 by tamahome Link to comment Share on other sites More sharing options...
AlienStar Posted August 11, 2009 Share Posted August 11, 2009 hello everybody how can add a condition for this script ???? I mean : if ( width <= 800 ^ Height <= 600 ) change to 1024x768 and even if one of them ( width or height ) was <= last value also change to 1024x768 I mean I wanna the width > 800 and the height > 600 but if the resolution was bigger than 800x600 for example (1152x864) don't do any thing thanks so much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now