Login | |
|
 |
Changing Screen Reolution - 4/25/2005 10:34:41 PM
|
|
 |
|
| |
TNO
Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
Greetings once again. Can anyone translate the following into vbscript? Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long Private Const CCDEVICENAME = 32 Private Const CCFORMNAME = 32 Private Const DM_BITSPERPEL = &H60000 Private Const DM_PELSWIDTH = &H80000 Private Const DM_PELSHEIGHT = &H100000 Private Type DEVMODE dmDeviceName As String * CCDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type ' Inputs:Dim RetValue As Integer RetValue = ChangeRes(800, 600, 32) ' ' Returns:1 = Resolution Successfully Ch ' anged 0 = Resolution Was Not Changed Function ChangeRes(Width As Single, Height As Single, BPP As Integer) As Integer On Error GoTo ERROR_HANDLER Dim DevM As DEVMODE, I As Integer, ReturnVal As Boolean, _ RetValue, OldWidth As Single, OldHeight As Single, _ OldBPP As Integer Call EnumDisplaySettings(0&, -1, DevM) OldWidth = DevM.dmPelsWidth OldHeight = DevM.dmPelsHeight OldBPP = DevM.dmBitsPerPel I = 0 Do ReturnVal = EnumDisplaySettings(0&, I, DevM) I = I + 1 Loop Until (ReturnVal = False) DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL DevM.dmPelsWidth = Width DevM.dmPelsHeight = Height DevM.dmBitsPerPel = BPP Call ChangeDisplaySettings(DevM, 1) RetValue = MsgBox("Do You Wish To Keep Your Screen Resolution To " & Width & "x" & Height & " - " & BPP & " BPP?", vbQuestion + vbOKCancel, "Change Resolution Confirm:") If RetValue = vbCancel Then DevM.dmPelsWidth = OldWidth DevM.dmPelsHeight = OldHeight DevM.dmBitsPerPel = OldBPP Call ChangeDisplaySettings(DevM, 1) MsgBox "Old Resolution(" & OldWidth & " x " & OldHeight & ", " & OldBPP & " Bit) Successfully Restored!", vbInformation + vbOKOnly, "Resolution Confirm:" ChangeRes = 0 Else ChangeRes = 1 End If Exit Function ERROR_HANDLER: ChangeRes = 0 End Function
_____________________________
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
| |
|
|
|
 |
Re: Changing Screen Reolution - 4/25/2005 10:53:56 PM
|
|
 |
|
| |
TNO
Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: online
|
Did I really type "Reolution"?...[V] ....Resolution.
|
|
| |
|
|
|
 |
Re: Changing Screen Reolution - 4/26/2005 8:37:05 AM
|
|
 |
|
| |
didorno
Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
|
I understand now that the language is Visual Basic. Pure vbscript to change the display resolution seems not possible. Maybe you can use the next info quote: From:Torgeir Bakken (Torgeir.Bakken-spam@hydro.com) Onderwerp:Re: Script to change display resolution? View this article only Discussies:microsoft.public.scripting.wsh Datum:2001-12-01 08:10:12 PST WSH has no build in functionality for this. MultiRes may do what you want. Its a screen resolutions utility that can be used from the command line, a shortcut or a script :-) MultiRes (50kb) is a 32-bit alternative to QuickRes, which adds refresh rate and multi- monitor support, as well as optional timed confirmation prompts. The little utility supports Windows 9x/Me/NT4, as well as Windows 2000 and XP It's available at http://168.144.101.149/files/multires.exe (Entech Taiwan), and can be used to set screen resolution, color depth, and refresh rate. Normally it runs with an icon in the notification area. But it's also possible to run it in non-resident command mode in a batch file. There's more info in that at http://www.entechtaiwan.com/multires.htm So, you can use it to set startup resolutions by creating a simple, 1 line, batch file and placing it in each user's startup profile. e.g. two command lines: User 1 - runs at 800x600, 32-bit color, 85Hz refresh d:\multires\multires.exe /800,600,32,85 /exit User 2 - runs at 1024x768, 32-bit color, 90Hz refresh d:\multires\multires.exe /1024,768,32,90 /exit -- torgeir Lieh wrote: > Is it possible to use WSH to automatically adjust my display resolution? > Ideally, I would like a supercharged shortcut to launch the VB IDE and set > my display resolution to 1280 x 1024. I am sick of changing it back and > forth manually all of the time. > > Thanks, > Lieh
Good luck !
|
|
| |
|
|
|
|
|