Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Changing Screen Reolution

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2802
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Changing Screen Reolution
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 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
 
 
Post #: 1
 
 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.

(in reply to TNO)
 
 
Post #: 2
 
 Re: Changing Screen Reolution - 4/26/2005 7:58:15 AM   
  didorno

 

Posts: 361
Score: 0
Joined: 2/12/2005
From:
Status: offline
quote:
Originally posted by TNO

Did I really type "Reolution"?...[V] ....Resolution.


No problem, my brains are in the autocorrection mode, which
means the "s" is added instantly.

About your question, what is the original scripting language ?

(in reply to TNO)
 
 
Post #: 3
 
 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 !

(in reply to TNO)
 
 
Post #: 4
 
 Re: Changing Screen Reolution - 4/26/2005 10:46:38 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
http://www.spoogenet.com/index.php?module=article&view=12&5cbaa9d36385e275f0a415eb9b827618=e3284fc043df32fcd035ba65d4febb6c

(in reply to TNO)
 
 
Post #: 5
 
 Re: Changing Screen Reolution - 4/26/2005 2:28:43 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I don't believe it can be translated into vbs code and I don't think you can do that in using only WMI. Check out the URLs posted by others.

(in reply to TNO)
 
 
Post #: 6
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Changing Screen Reolution Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts