Author Topic: Caps Lock On  (Read 3079 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7527
Caps Lock On
« on: January 03, 2005, 05:50:34 PM »
Is there a way to turn the caps lock on via lisp?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

hyposmurf

  • Guest
Caps Lock On
« Reply #1 on: January 03, 2005, 06:16:42 PM »
Not a lisp but a add on program for windows.Isnt it just easier to toggle the caps lock key or are you talking about changing the case of already inputed text to uppercase via lisp?
converting to uppercase

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Re: Caps Lock On
« Reply #2 on: January 03, 2005, 06:36:10 PM »
Quote from: ronjonp
Is there a way to turn the caps lock on via lisp?

Yes, sort of. There is a routine called AutoLay3.0 available on the web that has a caps locker included. I think it uses DOSLib.

I have a VBA solution that I 've been using for over a year that is pretty customizable as far as which commands need Uppercase. I can post it if you'd like.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Caps Lock On
« Reply #3 on: January 03, 2005, 08:48:56 PM »
do it .... if I can make all of my text enter default as caps when I execute a text editing program, that would be cool..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Caps Lock On
« Reply #4 on: January 03, 2005, 09:25:39 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7527
Caps Lock On
« Reply #5 on: January 04, 2005, 10:29:26 AM »
Jeff,

Would you please post your VBA solution for this?

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Caps Lock On
« Reply #6 on: January 04, 2005, 01:12:43 PM »
Here ya go. In Acad, type VBAMAN; create a new file; Save As Acad.dvb; go to the VBA Editor; double click on ThisDrawing in thye tree view to the left; pasre this code into the code window for ThisDrawing:
Code: [Select]

'''Subs by Mark Propst, posted to the autodesk VBA newsgroup
'''June 23, 2003

Option Explicit
Dim kb As clsKeyboard
Dim command_count As Long

Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
  Select Case UCase(CommandName)
    Case UCase("mtext"), UCase("text"), UCase("mtedit"), UCase("dtext"), _
         UCase("ddedit"), UCase("ddatte"), UCase("QLEADER"), UCase("Layer")
'add whatever other commands you may want CapsOn for, both here and the EndCommand event.
      Set kb = New clsKeyboard
      kb.CapsOn = True
      Case Else
        If Not kb Is Nothing Then
            kb.CapsOn = False
            Set kb = Nothing
        End If
  End Select

End Sub

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
  Select Case CommandName
    Case UCase("mtext"), UCase("text"), UCase("mtedit"), UCase("dtext"), _
         UCase("ddedit"), UCase("ddatte"), UCase("QLEADER"), UCase("Layer")

    kb.CapsOn = False
    If Not kb Is Nothing Then
        Set kb = Nothing
    End If
  End Select

Now, go to the Insert menu, select Class Module; right click the new Class it creates and rename to clsKeyboard; double click to open the code window for it; add this code to the class:
Code: [Select]

Option Explicit
'''Functions by Bobby C. Jones of AcadX.com

Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1

Private Type KeyboardBytes
    kbByte(0 To 255) As Byte
End Type

Private Type OSVERSIONINFO
    dwOSVerInfoSize As Long
    dwMajorVer As Long
    dwMinorVer As Long
    dwBuildNumber As Long
    dwPlatformID As Long
    szCSDVer As String * 128
End Type

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" (keys As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (keys As KeyboardBytes) As Long

Private keys As KeyboardBytes


'* * * * * * * * * * * * *
'Public Members
'* * * * * * * * * * * * *

Public Property Get CapsOn() As Boolean
   CapsOn = GetKeyStatus(VK_CAPITAL)
End Property

Public Property Let CapsOn(ByVal bValue As Boolean)
   setKey VK_CAPITAL, bValue
End Property

Public Property Get NumLockOn() As Boolean
   NumLockOn = GetKeyStatus(VK_NUMLOCK)
End Property

Public Property Let NumLockOn(ByVal bValue As Boolean)
   setKey VK_NUMLOCK, bValue
End Property

Public Property Get ScrollOn() As Boolean
   ScrollOn = GetKeyStatus(VK_SCROLL)
End Property

Public Property Let ScrollOn(ByVal bValue As Boolean)
   setKey VK_SCROLL, bValue
End Property


'* * * * * * * * * * * * *
'Private functions
'* * * * * * * * * * * * *

Private Sub setKey(vkKey As Long, onVal As Boolean)
    Dim OS As OSVERSIONINFO
    Dim keyState As Boolean

    'get OS info
    OS.dwOSVerInfoSize = Len(OS)
    GetVersionEX OS

    'Get the keyboard state
    GetKeyboardState keys

    'Get the key state
    keyState = keys.kbByte(vkKey)

    'Change a key
    If keyState <> onVal Then
        If OS.dwPlatformID = VER_PLATFORM_WIN32_NT Then
            'simulate key press
            keybd_event vkKey, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
            'simulate key release
            keybd_event vkKey, &H45, KEYEVENTF_EXTENDEDKEY Or _
                                KEYEVENTF_KEYUP, 0
          Else
            keys.kbByte(vkKey) = Abs(onVal)
            SetKeyboardState keys
        End If
    End If
End Sub

Private Function GetKeyStatus(vkKey As Long) As Boolean
    'get the keyboard state
    GetKeyboardState keys
    'get and return the key state
    GetKeyStatus = keys.kbByte(vkKey)
End Function


If you need help making Acad autoload the acad.dvb, refer to the help docs. The process is slightly different for different versions.

ronjonp

  • Needs a day job
  • Posts: 7527
Caps Lock On
« Reply #7 on: January 04, 2005, 02:59:29 PM »
Thanks Jeff. I'll give it a try in a bit :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC