View Full Version : capslock
ehpjr
12-31-2001, 01:44 AM
I have written the following script to make sure CAPSLOCK is on when I open the file data.wdb and to turn CAPSLOCK off after I close the file. This script works fine the first time I run it. If I run it again the CAPSLOCK LED flashes like it is trying to come on but doesn't stay on and CAPSLOCK is not on. What is going on? What command can I use to check the system variable for CAPSLOCK and determine if it is on or not??
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "{capslock}"
WshShell.Run "c:\data.wdb", 1, true
WshShell.SendKeys "{capslock}"
adamdelves
12-31-2001, 07:09 AM
I have tried running the script opening a notepad document. I don't appear to have any problems. However there may be a problem in one of the arguments.
WShShell.Run(path As String, windowStyle,
waitOnReturn As Boolean)
The third argument which you specified TRUE for causes the script to wait and pick up any error codes generated by the program before continuing.
This means that any error generated by the program causes the script to continue- If an error occurs as the file opens then the CAPS LOCK will appear to flash on and off.
Closing the program also generates an error and provided the program opens and runs with no errors the script will not continue until you close it.
Make the following changes to your script to see if you can find out what is causing the error:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "{capslock}"
return = WshShell.Run("c:\data.wdb", 1, true)
WshShell.SendKeys "{capslock}"
on error resume next
err.raise return
msgbox err.description
This should give a description of the error raised by the program.
ehpjr
01-03-2002, 02:54 PM
Thanks. The error message I got was "Invalid Procedure Call or Argument." Must be something to do with MS Works. I'm going to try starting some other applications and see what happens.
Powered by vBulletin™ Version 4.1.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.