August 5th, 1999, 08:06 AM
There's really no reward beyond the gratitute of a billion dollar enterprise with one pathetic NT administrator, but I figured it would get you to at least look at my question. My question is this. I have a user who wanted his caps lock and num lock to automatically turn on when he booted his machine. I enabled the num lock through the regedit utility in NT but I can't figure out how to get the CAPS LOCK. Some gurus Ive spoken to says it cant be done through NT but there may be a way to do it with VB code. My old job was a Vb programmer so if someone can give me some ideas how to do it, I'd be happy to give it a shot, or if you think it cant be done let me know that too.
Gorditos
August 5th, 1999, 09:19 PM
You can set the CAPS Lock on through VB code. I wrote a little program that will work for NT.
What you do is start a new project ... add a module (Project ... AddModule)
Add the following Code.
Option Explicit
Dim kBuf(0 To 255) As Byte
Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const VK_CAPITAL = &H14
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Sub Main()
GetKeyboardState kBuf(0)
If kBuf(VK_CAPITAL) = 0 Then
'Simulate Key Press
keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
'Simulate Key Release
keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY _
Or KEYEVENTF_KEYUP, 0
End If
End Sub
Then go to Project ... Project Properties ... and change the startup object to sub main. You can also remove Form1 through the project menu. Then compile it and add your nifty new program to the startup folder on the target computer and wala ... the Caps Lock will come on at startup, and all the folks at work will think you are a genius.
For more information on how to make this work for NT and Win95/98 see Microsoft Knowledge Base Article ID: Q177674.
Gordito Supreme