The script does not work all the time 
Author Message
 The script does not work all the time

I want to use this script to reduce the screen resolution:

' VB Script Document
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 500
WshShell.run "RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3",3,false
WScript.Sleep 500
WshShell.SendKeys "{tab}" 'here the problem starts
WScript.Sleep 500         'the window is not always activated?
WshShell.SendKeys "{left}"
WScript.Sleep 500
WshShell.SendKeys "{left}"
WScript.Sleep 500
WshShell.SendKeys "{left}"
WScript.Sleep 500
WshShell.SendKeys "{left}"
WScript.Sleep 500
WshShell.SendKeys "{enter}"
WScript.Sleep 500
WshShell.SendKeys "{left}"
WScript.Sleep 500      
WshShell.SendKeys "{enter}"
WScript.Sleep 500
WshShell.SendKeys "{enter}"



Thu, 14 Jul 2005 22:16:00 GMT  
 The script does not work all the time

Quote:

> I want to use this script to reduce the screen resolution:

> ' VB Script Document
> Dim WshShell
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WScript.Sleep 500
> WshShell.run "RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3",3,false
> WScript.Sleep 500
> WshShell.SendKeys "{tab}" 'here the problem starts (snip)

Hi

SendKeys solutions are very unreliable...

I suggest you use a command line utility to change the resolution instead:

MultiRes is free screen resolutions utility that can be used from the command
line, a batch file, a shortcut or a script :-)

MultiRes has 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://www.entechtaiwan.com/multires.htm  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.

Example on a command line:

Set 800x600, 32-bit color, 85Hz refresh

d:\multires\multires.exe /800,600,32,85 /exit

Some other products (command line):

A freeware utility called Resolution Changer:
http://www.myitforum.com/inc/upload/1365Vidchng.zip

Here's the description:
"Video Resolution Changer v1.0 - Tony Pombo. This command-line utility changes
the display resolution of the current display device, using several command-line

options. vidchng /? for help."

Here is a third product:

Vidres
http://www.jddesign.freeserve.co.uk/vidres.htm

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Fri, 15 Jul 2005 03:55:38 GMT  
 The script does not work all the time

Quote:

> I want to use this script to reduce the screen resolution:

> ' VB Script Document
> Dim WshShell
> Set WshShell = WScript.CreateObject("WScript.Shell")
> WScript.Sleep 500
> WshShell.run "RUNDLL32.EXE shell32.dll,Control_RunDLL desk.cpl,,3",3,false
> WScript.Sleep 500
> WshShell.SendKeys "{tab}" 'here the problem starts
> WScript.Sleep 500         'the window is not always activated?
> WshShell.SendKeys "{left}"
> WScript.Sleep 500
> WshShell.SendKeys "{left}"
> WScript.Sleep 500
> WshShell.SendKeys "{left}"
> (snip)

If you absolutely don't want to use a 3rd party command line utility, here is a
version that would work somewhat more reliably with SendKeys:

Set WshShell = CreateObject("WScript.Shell")

' Open the "Display Properties" with the
' "Settings" tab selected
WshShell.Run "control desk.cpl,,3"

' Wait for the "Display Properties" to show up
Do Until WshShell.AppActivate ("Display Properties")
  WScript.Sleep 100
Loop

WScript.Sleep 300
WshShell.SendKeys "{tab}"
' four lefts
WshShell.SendKeys "{left 4}"
' pressing enter
WshShell.SendKeys "{enter}"
(snip)

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and a ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter



Fri, 15 Jul 2005 04:13:12 GMT  
 The script does not work all the time
Thanks!
The main reason I use VBS is to use it for automating smaller tasks.
This was exactly what I was looking for!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Fri, 15 Jul 2005 14:15:16 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Why doe the BLUR not work in IE ???

2. Date() not working, time() and Now() do work

3. URGENT: Report works the first time, but not the second time

4. Herlp: LIKE in SQL doe not work anymore

5. Script works, script don't work

6. Run Time Scripting Doesn't Work as Windows Service

7. Run Time Scripting Doesn't Work as Windows Service

8. Valid script does not work with Scripting Object Model

9. Valid script does not work with Scripting Object Model

10. New To Scripting and Script does not work

11. New To Scripting and Script does not work

12. HELP PLEASE - Why does this script not work?

 

 
Powered by phpBB® Forum Software