We always use caps in cad so it drives me nuts writing emails etc and finding caps on. I think I have a solution thanks to
MP and dubb accidently yelling.
Even though this is virtually a straight copy it took an hour to figure out a way to make it shout when I wanted to. Api's are a bit tricky.
If there is a better way I'm all ears.
Option Explicit
Private WithEvents AutoCAD As AcadApplication
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetActiveWindow _
Lib "user32" () As Long
Private Declare Sub keybd_event _
Lib "user32" _
(ByVal virtualKeyCode As Byte, _
ByVal stubbed As Byte, _
ByVal flags As Long, _
ByVal pointerToExtraInfo As Long)
Private Declare Function MapVirtualKey _
Lib "user32" _
Alias "MapVirtualKeyA" _
(ByVal virtualKeyCode As Long, _
ByVal translate As Long) _
As Long
Private Declare Function GetKeyState _
Lib "user32" _
(ByVal virtualKeyCode As Long) _
As Long
Private Const _
VKC_CAPSLOCK = &H14, _
TRANSLATE_TO_SCANCODE = 0, _
SCANF_KEYUP = &H2, _
SCANF_KEYEXT = &H1, _
SCANF_KEYNOTEXT = &H0, _
NULL_POINTER = 0, _
SCANF_KEYDOWN = &H28
Public Sub Acadstartup()
Set AutoCAD = Application
AutoCAD.WindowState = acMax
ThisDrawing.WindowState = acMax
End Sub
Private Sub AutoCAD_AppActivate()
Set AutoCAD = Application
Dim Shout As Long
Dim Key As Long
Key = GetKeyState(VKC_CAPSLOCK)
If GetActiveWindow = FindWindow("wndclass_desked_gsk", vbNullString) Then
If Key = 1 Then
Shout = SCANF_KEYEXT Or SCANF_KEYNOTEXT
End If
Else
If Key = 0 Then
Shout = SCANF_KEYDOWN
End If
End If
If Shout Then ToggleShout (Shout)
End Sub
Private Sub AutoCAD_AppDeactivate()
If GetKeyState(VKC_CAPSLOCK) = 1 Then
ToggleShout (SCANF_KEYEXT)
End If
End Sub
Sub ToggleShout(Shout As Long)
Call keybd_event( _
VKC_CAPSLOCK, _
MapVirtualKey(VKC_CAPSLOCK, TRANSLATE_TO_SCANCODE), _
Shout Or SCANF_KEYNOTEXT, _
NULL_POINTER)
Call keybd_event( _
VKC_CAPSLOCK, _
MapVirtualKey(VKC_CAPSLOCK, TRANSLATE_TO_SCANCODE), _
Shout Or SCANF_KEYUP, _
NULL_POINTER)
End Sub