I used delay option 5, and it works for me.
You are my hero, Galapo!
![:cheers:](http://reboot.pro/public/style_emoticons/default/cheers.gif)
Posted 12 July 2010 - 11:27 AM
Posted 29 July 2010 - 07:38 PM
thats the (cut off) log from my ibm x60sVersion 5.6
[2010-07-29--21:25:00] Resolutions for "Mobile Intel® 945 Express Chipset Family (cdd)" device are:
\\.\DISPLAY1 : 320x200, 8bits, @40 Hz
\\.\DISPLAY1 : 320x200, 8bits, @40 Hz
......
\\.\DISPLAY1 : 1024x768, 8bits, @40 Hz
\\.\DISPLAY1 : 1024x768, 8bits, @50 Hz
\\.\DISPLAY1 : 1024x768, 16bits, @40 Hz
\\.\DISPLAY1 : 1024x768, 16bits, @50 Hz
\\.\DISPLAY1 : 1024x768, 32bits, @40 Hz
\\.\DISPLAY1 : 1024x768, 32bits, @50 Hz
\\.\DISPLAY1 : 1024x768, 32bits, @50 Hz
\\.\DISPLAYV2[not attached to desktop] : 0x0, 0bits, @0 Hz
\\.\DISPLAYV3[not attached to desktop] : 0x0, 0bits, @0 Hz
Best Low Res function successfully set to: 640x480, 32bits.
Native Machine detected
Error: BestRes function could not be set to 1024x768, 32bits on \\.\DISPLAY1. Current res is: 640x480, 32bits, @50Hz.
*** ***
Posted 29 July 2010 - 11:07 PM
Posted 31 July 2010 - 02:15 PM
no, native on laptop.I assume this is a Win7 PE?
... and it's interesting that setres works. Do you know what function it calls to set resolution, or if it does something additional like in the current case where ChangeDisplaySettings isn't working properly?
/*------------------------------------------------------------------------------------------ SETRES SINGLE MONITOR Windows command line program to set display resolution / colour depth / refresh frequency © 2010 Ian Sharpe (www.iansharpe.com) This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. The GNU General Public License can be viewed at [url="http://www.gnu.org/licenses/"]http://www.gnu.org/licenses/[/url]COMPATIBILITY Windows 98, Windows 2000 & laterCOMPILATION This version compiles without alteration using GCC in conjunction with the Bloodshed Dev-C++ IDE. Modification to work with other compilers is usually just a matter of getting the correct #INCLUDEs.VERSION HISTORY 30 April 2010 v2.3 : Initial GPL3 open source release Prior to v2.3 : Closed sourceMULTIPLE DISPLAYS SETRES SINGLE MONITOR works with the primary display only. A closed-source multi-monitor edition is available at www.iansharpe.com------------------------------------------------------------------------------------------*///----------------------------------------------------------------------------------------// INCLUDES// Compilers other than GCC may require different/additional include libraries.#include <stdio.h>#include <windows.h>#include <conio.h>//----------------------------------------------------------------------------------------// FORWARD DECLARATIONS//void ExitWithHelp(char *);void waitkey(void);//----------------------------------------------------------------------------------------// GLOBALS//const char* APP_VERSION = "v2.3 - 30 Apr 2010"; // Application version & dateBOOL bNoWait; // TRUE if user specifies not to wait for keypress on error//----------------------------------------------------------------------------------------// APP ENTRY POINT//int main( int argc, char* argv[] ){ DEVMODE DevMode; // Device mode structure - see Windows API documentation DWORD dwNewHres, // User-specified new horizontal resolution dwNewVres, // User-specified new vertical resolution dwNewBitDepth, // User-specified new colour (bit) depth dwNewFreq; // User-specified new frequency // Parse command line parameters dwNewHres = dwNewVres = dwNewBitDepth = dwNewFreq = 0; bNoWait = FALSE; for ( int i = 1; i < argc; i++ ) { _strupr(argv[i]); switch(argv[i][0]) { case 'H': // Horizontal res dwNewHres = atoi(&argv[i][1]); break; case 'V': // Vertical res dwNewVres = atoi(&argv[i][1]); break; case 'B': // Bit depth dwNewBitDepth = atoi(&argv[i][1]); break; case 'F': // Frequency dwNewFreq = atoi(&argv[i][1]); break; case 'N': // No wait for keypress on error bNoWait = TRUE; break; default: ExitWithHelp("Unrecognised parameter supplied"); } } // Parameter count check - after parsing in case user specified N = no wait parameter if ( argc < 3 || argc > 6 ) ExitWithHelp("Wrong number of command line parameters supplied."); // Uncomment for debugging /* printf("dwNewHres=%d\ndwNewVres=%d\ndwNewBitDepth=%d\ndwNewFreq=%d", dwNewHres, dwNewVres, dwNewBitDepth, dwNewFreq); getchar(0); exit(0); */ // Check we have sufficient information if( dwNewHres < 640 || dwNewVres < 480 ) ExitWithHelp("Valid horizontal and/or vertical size not specified. 640x480 minimum."); // Obtain current display settings if( ! EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS, &DevMode) ) { puts("FATAL ERROR: EnumDisplaySettings function failed.\nSomething went badly wrong. I don't know what. Sorry."); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); } // Overwrite with user-specified settings DevMode.dmPelsWidth = dwNewHres; DevMode.dmPelsHeight = dwNewVres; DevMode.dmFields = DM_PELSWIDTH+DM_PELSHEIGHT; if( dwNewBitDepth) { DevMode.dmBitsPerPel = dwNewBitDepth; DevMode.dmFields += DM_BITSPERPEL; } if (dwNewFreq) { DevMode.dmDisplayFrequency = dwNewFreq; DevMode.dmFields += DM_DISPLAYFREQUENCY; } // Execute resolution change, interpret API return code & exit puts ("Display mode change requested and Windows replied...\t"); switch (ChangeDisplaySettings(&DevMode, CDS_UPDATEREGISTRY)) { case DISP_CHANGE_SUCCESSFUL: puts("The settings change was successful"); exit(EXIT_SUCCESS); case DISP_CHANGE_RESTART: puts("The computer must be restarted in order for the graphics mode to work"); puts("PRESS A KEY"); waitkey(); exit(EXIT_SUCCESS); case DISP_CHANGE_BADFLAGS: puts("An invalid set of flags was passed in"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); case DISP_CHANGE_BADPARAM: puts("An invalid parameter was passed in. This can include an invalid flag or combination of flags"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); case DISP_CHANGE_FAILED: puts("The display driver failed the specified graphics mode"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); case DISP_CHANGE_BADMODE: puts("The graphics mode is not supported"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); case DISP_CHANGE_NOTUPDATED: puts("Windows NT: Unable to write settings to the registry"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); default: puts("with an unknown return code (possibly an error)"); puts("PRESS A KEY"); waitkey(); exit(EXIT_FAILURE); }}//----------------------------------------------------------------------------------------// Exit app with help message//// ARGUMENTS// char* pszSpecialMessage : Pointer to special message string// RETURN// Does not return - exits app with failure code//void ExitWithHelp(char* pszSpecialMessage){ printf("\nSETRES SINGLE MONITOR - %s © Ian Sharpe - www.iansharpe.com \n", APP_VERSION); puts("Open source software released under GPLv3 or greater (www.gnu.org/licenses/)"); puts("==============================================================================="); puts("Change screen resolution, colour depth and refresh frequency in Windows\n"); puts("\tSETRES hXXXX vXXXX [bXX] [fXX] [n]\n"); puts("hXXXX = Horizontal size of screen in pixels Not optional. 640 minimum"); puts("vXXXX = Vertical size of screen in pixels Not optional. 480 minimum"); puts(" bXX = Bit (colour) depth such as 8, 16 24, 32 Optional"); puts(" fXX = Refresh frequncy in Hertz, e.g. 60, 75, 85 Optional"); puts(" n = No 'Press a key' wait in error report Optional"); puts("\nEXAMPLES:"); puts("\tSETRES h1024 v768"); puts("\tSETRES h800 v600 b24"); puts("\tSETRES h1280 v1024 b32 f75"); puts("\tSETRES h1024 v768 n\n"); puts("\nWARNING: SETRES does not check the capabilities of your hardware. Windows"); puts("\tis supposed to reject unsupported settings but do not rely on this."); puts("\tIf you specify unsupported settings, I WILL NOT ACCEPT RESPONSIBILITY.\n"); printf("*** ERROR: %s ***\n", pszSpecialMessage); Beep(300, 200); waitkey(); exit(EXIT_FAILURE);}//----------------------------------------------------------------------------------------// Wait for keypress//void waitkey(void){ if ( bNoWait ) // Return immediately if bNoWait flag set return; int iCountDown; // Remaining seconds to timeout for( iCountDown = 15; ! kbhit() && iCountDown; iCountDown-- ) // 15 and Sleep(1000) = 15 seconds { printf(" PRESS A KEY - TIMEOUT IN %2d SECONDS - SEE SETRES.TXT FOR HELP\r", iCountDown); Sleep(1000); // Delay in loop cuts processor usage } if (iCountDown) getch(); // Throw character away Beep(300, 200);}//----------------------------------------------------------------------------------------// END//----------------------------------------------------------------------------------------
Posted 01 August 2010 - 04:02 AM
Posted 02 August 2010 - 07:43 PM
could this be the problem?MSDN ChangeDisplaySettings
The dmSize member of DEVMODE must be initialized to the size, in bytes, of the DEVMODE structure.
The dmDriverExtra member of DEVMODE must be initialized to indicate the number of bytes of private driver data following the DEVMODE structure.
Posted 03 August 2010 - 07:09 AM
Posted 03 August 2010 - 12:41 PM
no, does not work.I've made an alteration. Can you test the version I've uploaded here: http://galapo.boot-l...tResolution.exe
Thanks,
Galapo.
Posted 03 August 2010 - 11:51 PM
Hmm, I wonder why. I'm a little reluctant to do this the way SetRes does by calling with CDS_UPDATEREGISTRY without a prior CDS_TEST.no, does not work.
_ScreenSetting(1024, 768, 32, 50) ;=============================================================================== ===== ; ;Function Name: _ScreenSetting() ;Description: Changes the screen resolution, color dept and refresh rate ;Version: 1.0 ;Parameters: $iWidth - Width of the desktop screen in pixels. (horizontal resolution) ; $iHeight - Height of the desktop screen in pixels. (vertical resolution) ; $iDepth - Depth of the desktop screen in bits per pixel. ; $iRefresh - Refresh rate of the desktop screen in hertz. ;Return Value(s): On Success - Screen is adjusted ; On failure - Message with error description ;Requirement(s): Tested on AutoIt 3.2.10.0 ;Autor(s): R.Gilman (a.k.a rasim); special thanks to amel27 ; ;=============================================================================== ===== Func _ScreenSetting($iWidth = @DesktopWidth, $iHeight = @DesktopHeight, $iDepth = @DesktopDepth, $iRefresh = @DesktopRefresh) Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_FAILED = -1 Local Const $DISP_CHANGE_BADMODE = -2 Local Const $DISP_CHANGE_NOTUPDATED = -3 Local Const $DISP_CHANGE_BADFLAGS = -4 Local Const $DISP_CHANGE_BADPARAM = -5 Local Const $CDS_TEST = 0x4 Local Const $CDS_UPDATEREGISTRY = 0x1 Local Const $DM_PELSWIDTH = 0x80000 Local Const $DM_PELSHEIGHT = 0x100000 Local Const $DM_BITSPERPEL = 0x40000 Local Const $DM_DISPLAYFREQUENCY = 0x400000 Local Const $ENUM_CURRENT_SETTINGS = -1 Local Const $WM_DISPLAYCHANGE = 0x007E Local Const $HWND_BROADCAST = 0xFFFF Local Const $SPI_SETNONCLIENTMETRICS = 0x2A Local $DEVMODE, $DllRet $DEVMODE = DllStructCreate("char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields;short dmOrientation;short dmPaperSize;short dmPaperLength;" & _ "short dmPaperWidth;short dmScale;short dmCopies;short dmDefaultSource;short dmPrintQuality;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency") $DllRet = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, _ "ptr", DllStructGetPtr($DEVMODE)) $DllRet = $DllRet[0] If $DllRet = 0 Then MsgBox(16, "Error", "Unable to get graphic mode") Return False EndIf $VGA_MAP_KEY = RegRead("HKLM\HARDWARE\DEVICEMAP\VIDEO", "\Device\Video0") $VGA_KEY = StringReplace($VGA_MAP_KEY, "\Registry\Machine", "HKLM") RegWrite($VGA_KEY, "PruningMode", "REG_DWORD", 0) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) DllStructSetData($DEVMODE, "dmPelsWidth", $iWidth) DllStructSetData($DEVMODE, "dmPelsHeight", $iHeight) DllStructSetData($DEVMODE, "dmBitsPerPel", $iDepth) DllStructSetData($DEVMODE, "dmDisplayFrequency", $iRefresh) DllStructSetData($DEVMODE, "dmFields", BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY)) $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) $DllRet = $DllRet[0] If $DllRet <> $DISP_CHANGE_SUCCESSFUL Then Switch $DllRet Case $DISP_CHANGE_RESTART MsgBox(48, "Warning", "Restart your computer for change display settings") Case $DISP_CHANGE_FAILED MsgBox(16, "Error", "The video driver not set a new mode") Return False Case $DISP_CHANGE_BADMODE MsgBox(16, "Error", "Video mode not supported") Return False Case $DISP_CHANGE_NOTUPDATED MsgBox(16, "Error", "Unable to write in registry") Return False Case $DISP_CHANGE_BADFLAGS MsgBox(16, "Error", "Bad flags") Return False Case $DISP_CHANGE_BADPARAM MsgBox(16, "Error", "Bad parameters") Return False EndSwitch EndIf $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) $DllRet = $DllRet[0] DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $SPI_SETNONCLIENTMETRICS, "int", 0) RegWrite($VGA_KEY, "PruningMode", "REG_DWORD", 1) $DEVMODE = "" $DllRet = "" EndFunc
Sorry, I'm not sure what you're meaning. Please describe a bit more of what's happening.by the way: how do i stop it from evaluating resolutions again and again, switching between 640x480 and 800x600 (after i closed the helpwindow)?
whats the commandline, to switch resolution and exit without further actions?
Posted 11 August 2010 - 05:22 PM
worksCan you please test this more full code and see what happens:
if i simply start setresolution.exe and close the help-dialog, it evaluates resolutions again and again (switching between them), but does not succeed with 1024x768. only 800x600 and 640x480 where set.Sorry, I'm not sure what you're meaning. Please describe a bit more of what's happening.
Posted 12 August 2010 - 06:47 AM
Posted 13 August 2010 - 08:17 PM
Posted 16 August 2010 - 07:03 AM
Posted 16 August 2010 - 07:38 AM
Posted 16 August 2010 - 09:06 AM
DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $iDepth, "int", $iHeight * 2 ^ 16 + $iWidth)
Posted 19 August 2010 - 06:58 PM
Posted 19 August 2010 - 09:21 PM
Posted 20 August 2010 - 10:32 PM
Posted 21 August 2010 - 12:46 AM
Thanks for the report. I found the bug -- it was happening when running from the commandline only without SetResolution already running.it does revert back to 1024x768.
I see what you mean. When using DisplayProperties and clicking 'Apply', then maximised state windows are sized correctly and other windows that would have been off the screen are moved into view. I'm not sure how to do this. I'll send you the sourcecode for you to have a try.and the windows, maximised under 1024x768 stay in maximised state, but with windowsize 800x600. i have to click the maximisebutton twice, to unmaximise and then remaximise to windowsize 1024x768.
Posted 24 August 2010 - 06:59 PM
;=============================================================================== ;Function Name: _ScreenSetting() ;Description: Changes the screen resolution, color dept and refresh rate ;Version: 1.0 ;Parameters: $iWidth - Width of the desktop screen in pixels. (horizontal resolution) ; $iHeight - Height of the desktop screen in pixels. (vertical resolution) ; $iDepth - Depth of the desktop screen in bits per pixel. ; $iRefresh - Refresh rate of the desktop screen in hertz. ;Return Value(s): On Success - Screen is adjusted ; On failure - Message with error description ;Requirement(s): Tested on AutoIt 3.2.10.0 ;Autor(s): R.Gilman (a.k.a rasim); special thanks to amel27 ; ;============================================================================ === Func _ScreenSetting($i_Width = @DesktopWidth, $i_Height = @DesktopHeight, $i_Depth = @DesktopDepth, $i_Refresh = @DesktopRefresh) Local Const $DM_PELSWIDTH = 0x80000 Local Const $DM_PELSHEIGHT = 0x100000 Local Const $DM_BITSPERPEL = 0x40000 Local Const $DM_DISPLAYFREQUENCY = 0x400000 Local Const $ENUM_CURRENT_SETTINGS = -1 Local Const $WM_DISPLAYCHANGE = 0x007E Local Const $HWND_BROADCAST = 0xFFFF Local Const $SPI_SETNONCLIENTMETRICS = 0x2A Local $DEVMODE, $DllRet Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_FAILED = -1 Local Const $DISP_CHANGE_BADMODE = -2 Local Const $DISP_CHANGE_NOTUPDATED = -3 Local Const $DISP_CHANGE_BADFLAGS = -4 Local Const $DISP_CHANGE_BADPARAM = -5 Local Const $CDS_TEST = 0x4 Local Const $CDS_UPDATEREGISTRY = 0x1 $DEVMODE = DllStructCreate("char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields;short dmOrientation;short dmPaperSize;short dmPaperLength;" & _ "short dmPaperWidth;short dmScale;short dmCopies;short dmDefaultSource;short dmPrintQuality;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency") $DllRet = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, "ptr", DllStructGetPtr($DEVMODE)) $DllRet = $DllRet[0] If $DllRet = 0 Then MsgBox(16, "Error", "Unable to get graphic mode") Return False EndIf DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) DllStructSetData($DEVMODE, "dmPelsWidth", $iWidth) DllStructSetData($DEVMODE, "dmPelsHeight", $iHeight) DllStructSetData($DEVMODE, "dmBitsPerPel", $iDepth) DllStructSetData($DEVMODE, "dmDisplayFrequency", $iRefresh) DllStructSetData($DEVMODE, "dmFields", BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY)) $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) $DllRet = $DllRet[0] If $DllRet <> $DISP_CHANGE_SUCCESSFUL Then Switch $DllRet Case $DISP_CHANGE_RESTART MsgBox(48, "Warning", "Restart your computer for change display settings") Case $DISP_CHANGE_FAILED MsgBox(16, "Error", "The video driver not set a new mode") Return False Case $DISP_CHANGE_BADMODE MsgBox(16, "Error", "Video mode not supported") Return False Case $DISP_CHANGE_NOTUPDATED MsgBox(16, "Error", "Unable to write in registry") Return False Case $DISP_CHANGE_BADFLAGS MsgBox(16, "Error", "Bad flags") Return False Case $DISP_CHANGE_BADPARAM MsgBox(16, "Error", "Bad parameters") Return False EndSwitch EndIf $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) $DllRet = $DllRet[0] DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, "int", $i_BitsPP, "int", $i_Height * 2 ^ 16 + $i_Width) $DEVMODE = "" $DllRet = "" EndFunc
Posted 25 August 2010 - 03:48 AM
Posted 25 August 2010 - 07:54 AM
Posted 25 August 2010 - 11:06 AM
;=============================================================================== ; ;Function Name: _ScreenSetting() ;Description: Changes the screen resolution, color dept and refresh rate ;Version: 1.1 ;Parameters: $iWidth - Width of the desktop screen in pixels. (horizontal resolution) ; $iHeight - Height of the desktop screen in pixels. (vertical resolution) ; $iDepth - Depth of the desktop screen in bits per pixel. ; $iRefresh - Refresh rate of the desktop screen in hertz. ;Return Value(s): On Success - Screen is adjusted ; On failure - Message with error description ;Requirement(s): Tested on AutoIt 3.2.10.0 ;Autor(s): R.Gilman (a.k.a rasim); special thanks to amel27 ; 1.1 Galapo updated function to resize windows in line with resolution change ; ;=============================================================================== #include <WinAPI.au3> Func _ChangeScreenRes($iWidth = @DesktopWidth, $iHeight = @DesktopHeight, $iDepth = @DesktopDepth, $iRefresh = @DesktopRefresh) If $iWidth = "" Or $iWidth = -1 Or $iWidth = Default Then $iWidth = @DesktopWidth If $iHeight = "" Or $iHeight = -1 Or $iHeight = Default Then $iHeight = @DesktopHeight If $iDepth = "" Or $iDepth = -1 Or $iDepth = Default Then $iDepth = @DesktopDepth If $iRefresh = "" Or $iRefresh = -1 Or $iRefresh = Default Then $iRefresh = @DesktopRefresh Local Const $DISP_CHANGE_SUCCESSFUL = 0 Local Const $DISP_CHANGE_RESTART = 1 Local Const $DISP_CHANGE_FAILED = -1 Local Const $DISP_CHANGE_BADMODE = -2 Local Const $DISP_CHANGE_NOTUPDATED = -3 Local Const $DISP_CHANGE_BADFLAGS = -4 Local Const $DISP_CHANGE_BADPARAM = -5 Local Const $CDS_TEST = 0x4 Local Const $CDS_UPDATEREGISTRY = 0x1 Local Const $CDS_GLOBAL = 0x8 Local Const $DM_PELSWIDTH = 0x80000 Local Const $DM_PELSHEIGHT = 0x100000 Local Const $DM_BITSPERPEL = 0x40000 Local Const $DM_DISPLAYFREQUENCY = 0x400000 Local Const $ENUM_CURRENT_SETTINGS = -1 Local Const $WM_DISPLAYCHANGE = 0x007E Local Const $HWND_BROADCAST = 0xFFFF Local Const $SPI_SETNONCLIENTMETRICS = 0x2A Local Const $SPI_GETWORKAREA = 0x0030 Local $tRECT, $pRECT local $aRet Local $DEVMODE, $DllRet $DEVMODE = DllStructCreate("char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields;short dmOrientation;short dmPaperSize;short dmPaperLength;" & _ "short dmPaperWidth;short dmScale;short dmCopies;short dmDefaultSource;short dmPrintQuality;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency") $DllRet = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "dword", $ENUM_CURRENT_SETTINGS, _ "ptr", DllStructGetPtr($DEVMODE)) $DllRet = $DllRet[0] If $DllRet = 0 Then MsgBox(16, "Error", "Unable to get graphic mode") SetError(1) Return False EndIf $VGA_MAP_KEY = RegRead("HKLM\HARDWARE\DEVICEMAP\VIDEO", "\Device\Video0") $VGA_KEY = StringReplace($VGA_MAP_KEY, "\Registry\Machine", "HKLM") RegWrite($VGA_KEY, "PruningMode", "REG_DWORD", 0) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) DllStructSetData($DEVMODE, "dmPelsWidth", $iWidth) DllStructSetData($DEVMODE, "dmPelsHeight", $iHeight) DllStructSetData($DEVMODE, "dmBitsPerPel", $iDepth) DllStructSetData($DEVMODE, "dmDisplayFrequency", $iRefresh) DllStructSetData($DEVMODE, "dmFields", BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY)) $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST) $DllRet = $DllRet[0] If $DllRet <> $DISP_CHANGE_SUCCESSFUL Then Switch $DllRet Case $DISP_CHANGE_RESTART MsgBox(48, "Warning", "Restart your computer for change display settings") SetError(2) Case $DISP_CHANGE_FAILED MsgBox(16, "Error", "The video driver not set a new mode") SetError(1) Return False Case $DISP_CHANGE_BADMODE MsgBox(16, "Error", "Video mode not supported") SetError(1) Return False Case $DISP_CHANGE_NOTUPDATED MsgBox(16, "Error", "Unable to write in registry") SetError(1) Return False Case $DISP_CHANGE_BADFLAGS MsgBox(16, "Error", "Bad flags") SetError(1) Return False Case $DISP_CHANGE_BADPARAM MsgBox(16, "Error", "Bad parameters") SetError(1) Return False EndSwitch EndIf $DllRet = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY) $DllRet = $DllRet[0] ;DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ ; "int", $SPI_SETNONCLIENTMETRICS, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _ "int", $iDepth, "int", $iHeight * 2 ^ 16 + $iWidth) RegWrite($VGA_KEY, "PruningMode", "REG_DWORD", 1) $winlist = WinList() For $i = 1 to $winlist[0][0] If $winlist[$i][0] <> "" AND IsVisible($winlist[$i][1]) Then If BitAnd(WinGetState($winlist[$i][1]), 32) Then WinMove($winlist[$i][1],"",0,0,@DesktopWidth,@DesktopHeight) Else $winsize = WinGetPos($winlist[$i][1]) $tRECT = DllStructCreate($tagRECT) $pRECT = DllStructGetPtr($tRECT) $aRet = DllCall('user32.dll', 'int', 'SystemParametersInfo', 'uint', $SPI_GETWORKAREA, 'uint', 0, 'ptr', $pRECT, 'uint', 0) If Not @error And $aRet[0] Then $workarea_height = DllStructGetData($tRECT, 'Bottom') Else $workarea_height = @DesktopHeight EndIf If $winsize[0]+$winsize[2] > @DesktopWidth Then If $winsize[2] > @DesktopWidth - 10 Then WinMove($winlist[$i][1],"",10,default,@DesktopWidth - 20) Else WinMove($winlist[$i][1],"",10,default) EndIf EndIf If $winsize[1]+$winsize[3] > $workarea_height Then If $winsize[3] > $workarea_height - 10 Then WinMove($winlist[$i][1],"",default,10,default,$workarea_height - 20) Else WinMove($winlist[$i][1],"",default,10) EndIf EndIf EndIf EndIf Next $DEVMODE = "" $DllRet = "" EndFunc Func IsVisible($handle) If BitAnd(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc
Posted 08 August 2012 - 08:35 PM
AutoItv3 - SetResolution-x64.exe - Application Error
The instruction at 0x021ca3a0 referenced memory at 0x021ca3a0. The memory could not be written
Posted 17 September 2012 - 12:35 PM
0 members, 0 guests, 0 anonymous users