Your question, your audience. Choose who sees your identity—and your question—with question security.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
basically when form is activate presses capslock (if it's off) and when form is unloaded presses it again (if it's on)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_CAPITAL = &H14
Private Sub Form_Activate()
'' check if caps is pressed
If GetKeyState(VK_CAPITAL) <> 1 Then
'' turn caps on
keybd_event VK_CAPITAL, 0, 0, 0
keybd_event VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'' be nice turn caps off
If GetKeyState(VK_CAPITAL) = 1 Then
keybd_event VK_CAPITAL, 0, 0, 0
keybd_event VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0
End If
End Sub
however, i'd probably turn caps off either in form_Deactivate or lostfocus (i just can't get those events to fire in my test)