Thanks,
Jay Stubbs.
Regards,
PhilipB.
Declare Function GetKeyState Lib "USER32" (ByVal nVirtKey As Integer) As
Integer
Const VK_CAPITAL = &H14
Function GetCapsLockState() As Integer ''Returns True if CapsLock is On'
Dim fNumLock As Integer
fNumLock = GetKeyState(VK_CAPITAL)
If fNumLock And 1 Then GetCapsLockState = True
End Function
Sub Test()
If GetCapsLockState Then
MsgBox "CapsLock is ON.", 64, "RSL Business Solutions"
Else
MsgBox "Capslock is OFF.", 64, "RSL Business Solutions"
End If
End Sub
You could possibly use the following:
(in a standard module:)
---------------------------------------------------------
Declare Function GetKeyboardState Lib "user32.dll" (lpKeyState As Byte) As
Long
Declare Function SetKeyboardState Lib "user32.dll" (lpKeyState As Byte) As
Long
Sub SetCapsLock(CLState As Boolean)
全ub-procedure that sets the CapsLock to True or False
Dim KeyState(0 To 255) As Byte
GetKeyboardState KeyState(0)
If CBool(KeyState(vbKeyCapital)) = True Then
If CLState = True Then
Exit Sub
Else
KeyState(vbKeyCapital) = CByte(Abs(False))
End If
ElseIf CBool(KeyState(vbKeyCapital)) = False Then
If CLState = True Then
KeyState(vbKeyCapital) = CByte(Abs(True))
Else
Exit Sub
End If
End If
SetKeyboardState KeyState(0)
End Sub
Sub Caller1()
Call SetCapsLock(True)
End Sub
-----------------------------------------------------------------------
You can use the procedure calling the Caller1.
The procedure will work regardless of what the respective LED shows, so be
carefull to set it back to the state that the LED shows if you don't want to
confuse your user.
HTH
Regards,
Stratos