Author Topic: Caps  (Read 1509 times)

0 Members and 1 Guest are viewing this topic.

Bryco

  • Water Moccasin
  • Posts: 1849
Caps
« on: April 29, 2006, 04:29:16 PM »
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.

Code: [Select]
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

Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Caps
« Reply #1 on: April 29, 2006, 06:05:38 PM »
You might find THIS thread informational/useful

Bryco

  • Water Moccasin
  • Posts: 1849
Re: Caps
« Reply #2 on: April 30, 2006, 10:52:51 AM »
Good article. Do you need VB to get the download to work?

Jeff_M

  • King Gator
  • Posts: 3944
  • C3D user & customizer
Re: Caps
« Reply #3 on: April 30, 2006, 02:31:12 PM »
No, but there is a dll mentioned that you must have available.

Bryco

  • Water Moccasin
  • Posts: 1849
Re: Caps
« Reply #4 on: April 30, 2006, 05:48:12 PM »
All the dll's are in C:\WINNT\system32  but some of them are named in caps if that makes a difference.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16721
  • Superior Stupidity at its best
Re: Caps
« Reply #5 on: April 30, 2006, 10:00:09 PM »
Caps make no difference .. so long as the files are located in the system folder and are pointed to in the registry ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal