Check Caps lock Status

Check Caps lock Status

Anonymous
Not applicable
918 Views
6 Replies
Message 1 of 7

Check Caps lock Status

Anonymous
Not applicable
Hi
Can any one explain me hw to check wheather caps lock is on or off, i.e when user press the caps button if it is on I want to inform user through a msgbox.
Thanks.
0 Likes
919 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Check this URL
http://www.vbwereld.nl/forum/viewtopic.php?t=4409&highlight=&sid=0bb202ea350a3b41dc20772b20373239
0 Likes
Message 3 of 7

Anonymous
Not applicable
Thank you very much that was very usefull.

regards
Benny
0 Likes
Message 4 of 7

Anonymous
Not applicable
Benny

Did you see my post "Caps-lock on/off Program"? It might be something you
could use.

--

Thanks,
David M. Gardner
Change the DOT to reply

wrote in message news:[email protected]...
Thank you very much that was very usefull.

regards
Benny
0 Likes
Message 5 of 7

Anonymous
Not applicable
Thanks that gave me lot of good ideas.
0 Likes
Message 6 of 7

Anonymous
Not applicable
Hi that was very useful. Is there any way i could enter a text box in a form, then code it so that when a user starts to type in the text box and the CAPS LOCK is on a message box will come up telling the user?
0 Likes
Message 7 of 7

arcticad
Advisor
Advisor
David can you provide a link to your code.

Here is a simple Toggle that will Turn the Caps Lock key on when you are in Mtext
and turn it of when finished.
Code Modified from http://forums.devx.com/showthread.php?t=38468


{code}

' Declare Type for API call:
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type

' API declarations:

Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) 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)

Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long

Private Declare Function SetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long

' Constant declarations:
Const VK_CAPITAL = &H14
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Const VER_PLATFORM_WIN32_NT = 2
Const VER_PLATFORM_WIN32_WINDOWS = 1


Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
If CommandName = "MTEXT" Then
CapLock False
End If
End Sub
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
If CommandName = "MTEXT" Then
CapLock True
End If
End Sub


Sub CapLock(CapOn As Boolean)
Dim o As OSVERSIONINFO

Dim CapsLockState As Boolean

o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)


' CapsLock handling:
CapsLockState = keys(VK_CAPITAL)
If CapOn Then
If CapsLockState <> True Then 'Turn capslock on
GoSub Runit:
End If
Else
If CapsLockState <> False Then 'Turn capslock off
GoSub Runit:
End If
End If

Exit Sub
Runit:

If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then '=== Win95/98
keys(VK_CAPITAL) = 1
SetKeyboardState keys(0)
ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then '=== WinNT
'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

Sub isCapsLockON()

Dim o As OSVERSIONINFO
Dim CapsLockState As Boolean
o.dwOSVersionInfoSize = Len(o)
GetVersionEx o
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)

' CapsLock handling:
CapsLockState = keys(VK_CAPITAL)
If CapsLockState Then
MsgBox "Caps Lock is On"
Else
MsgBox "Caps Lock is Off"
End If

End Sub


{code}
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes