Author Topic: Caps Lock  (Read 18519 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Caps Lock
« Reply #15 on: April 10, 2012, 08:17:47 AM »
99% of what we type in AutoCAD is MText and so we simply toggle on the AUTOCAPS option for MText (right-click --> Autocaps).

My two cents....
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Caps Lock
« Reply #16 on: April 10, 2012, 08:43:13 AM »
@ Matt

I agree with the MTEXT autocaps, but we also do plain text as well as edit attributes.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Caps Lock
« Reply #17 on: April 10, 2012, 08:50:26 AM »
99% of what we type in AutoCAD is MText and so we simply toggle on the AUTOCAPS option for MText (right-click --> Autocaps).

My two cents....
The other downfall of that is, if you paste anything into an MText object (something typed from word) that isn't in all caps, it capitalized everything.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Caps Lock
« Reply #18 on: April 10, 2012, 09:56:29 AM »
MS Office applications (some of them) have a "CapsLock" property that can be checked, Autocad does not.  I couldn't find any good references (dll) that had a good way of checking for CapsLock.

So you silently invoke Word from ACAD to make the change...interesting!  I like the forward thinking!  :kewl:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Caps Lock
« Reply #19 on: April 10, 2012, 12:05:35 PM »
Someone suggested this http://www.eventghost.org/
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.

BlackBox

  • King Gator
  • Posts: 3770
Re: Caps Lock
« Reply #20 on: April 10, 2012, 12:34:43 PM »
Again, FWIW - I'm mainly doing this for fun... There's definitely some additions that I'd like to incorporate, and some streamlining I'd like to do, but sadly this is all I have time for at the moment.

Here are three LispFunction Methods (so far) aptly named CapsLock, NumLock, and ScrollLock.

Each LispFunction can be invoked on it's own without an argument, and the function serves as a check, returning T for ON, Nil for OFF.

When a single argument is supplied as either T for ON, or Nil for OFF the status is checked, and if needed, the status is changed per the supplied argument.

Example (CapsLock shown):

Code - Auto/Visual Lisp: [Select]
  1. Command: (capslock)
  2. nil
  3.  
  4. Command: (capslock t)
  5. T
  6.  
  7. Command: (CAPSLOCK)
  8. T
  9.  
  10. Command: (CAPSLOCK NIL)
  11. nil
  12.  
  13. Command: (capslock)
  14. nil
  15.  


The compiled code is attached (at the bottom of this post), and was compiled to .NET 3.5 to work with 2010 and newer, and has tested successfully with Civil 3D 2011, and 2012.

I hope someone will have use for this - Enjoy!


Here's the source code for those interested:



** Update - 2012-08-17

Additional 'LispException' Classes added for completeness (thanks Gile!), and attached the following assembly versions:

LispKeys2010.dll (compiled to .NET 3.5 for 2010 database format)
LispKeys2013.dll (compiled to .NET 4.0 for 2013 database format)

... Next enhancement will streamline, adding Methods (sub-functions) to remove duplicate code.



Code - vb.net: [Select]
  1. Imports Autodesk.AutoCAD.Runtime
  2. Imports Autodesk.AutoCAD.ApplicationServices
  3. Imports Autodesk.AutoCAD.DatabaseServices
  4. Imports Autodesk.AutoCAD.Geometry
  5. Imports Autodesk.AutoCAD.EditorInput
  6.  
  7. Imports System
  8. Imports System.Windows.Forms
  9.  
  10. Namespace LispKeys
  11.  
  12. #Region "myFunctions"
  13.  
  14.     Public Class MyFunctions
  15.  
  16.         Implements IExtensionApplication
  17.  
  18.         Public Sub Initialize() Implements IExtensionApplication.Initialize
  19.             Autodesk.AutoCAD.ApplicationServices.Application. _
  20.                 DocumentManager.MdiActiveDocument.Editor.WriteMessage(
  21.                     vbLf & "LispKeys Loaded. " & vbLf
  22.                     )
  23.         End Sub
  24.  
  25.         Public Sub Terminate() Implements IExtensionApplication.Terminate
  26.             ' Do plug-in application clean up here
  27.         End Sub
  28.  
  29.         Private Shared ed As Editor = Autodesk.AutoCAD.ApplicationServices. _
  30.             Application.DocumentManager.MdiActiveDocument.Editor
  31.  
  32.         Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
  33.                                                       ByVal bScan As Byte, _
  34.                                                       ByVal dwFlags As Integer, _
  35.                                                       ByVal dwExtraInfo As Integer)
  36. #Region "CapsLock"
  37.  
  38.         Shared Sub ToggleCapsLock()
  39.             keybd_event(System.Windows.Forms.Keys.CapsLock, &H14, 1, 0)
  40.             keybd_event(System.Windows.Forms.Keys.CapsLock, &H14, 3, 0)
  41.         End Sub
  42.  
  43.         <LispFunction("CapsLock")> _
  44.         Public Function CapsLock(ByVal args As ResultBuffer)
  45.             Try
  46.                 If args Is Nothing Then
  47.                     If My.Computer.Keyboard.CapsLock = True Then
  48.                         Return True
  49.                     Else
  50.                         Return Nothing
  51.                     End If
  52.                 End If
  53.  
  54.                 Dim myArgs As Array = args.AsArray
  55.  
  56.                 If myArgs.Length > 1 Then
  57.                     Throw New TooManyArgsException()
  58.                 End If
  59.  
  60.                 Dim arg As TypeCode = myArgs(0).Typecode
  61.  
  62.                 If arg = LispDataType.T_atom Then
  63.                     If My.Computer.Keyboard.CapsLock <> True Then
  64.                         ToggleCapsLock()
  65.                     End If
  66.                     Return True
  67.                 End If
  68.  
  69.                 If arg = LispDataType.Nil Then
  70.                     If My.Computer.Keyboard.CapsLock <> False Then
  71.                         ToggleCapsLock()
  72.                     End If
  73.                     Return Nothing
  74.                 End If
  75.  
  76.                 Throw New ArgumentTypeException("atom", myArgs(0))
  77.                 Return Nothing
  78.  
  79.             Catch ex As LispException
  80.                 ed.WriteMessage(vbLf & "LISP error: {0}" & vbLf, ex.Message)
  81.                 Return Nothing
  82.  
  83.             Catch ex As Autodesk.AutoCAD.Runtime.Exception
  84.                 ed.WriteMessage(vbLf & "AutoCAD error: {0}" & vbLf, ex.Message)
  85.                 Return Nothing
  86.  
  87.             Catch ex As System.Exception
  88.                 ed.WriteMessage(vbLf & "System error: {0}" & vbLf, ex.Message)
  89.                 Return Nothing
  90.  
  91.             End Try
  92.  
  93.         End Function
  94.  
  95. #End Region
  96.  
  97. #Region "NumLock"
  98.         Shared Sub ToggleNumLock()
  99.             keybd_event(System.Windows.Forms.Keys.NumLock, &H90, 1, 0)
  100.             keybd_event(System.Windows.Forms.Keys.NumLock, &H90, 3, 0)
  101.         End Sub
  102.  
  103.         <LispFunction("NumLock")> _
  104.         Public Function NumLock(ByVal args As ResultBuffer)
  105.             Try
  106.                 If args Is Nothing Then
  107.                     If My.Computer.Keyboard.NumLock = True Then
  108.                         Return True
  109.                     Else
  110.                         Return Nothing
  111.                     End If
  112.                 End If
  113.  
  114.                 Dim myArgs As Array = args.AsArray
  115.  
  116.                 If myArgs.Length > 1 Then
  117.                     Throw New TooManyArgsException()
  118.                 End If
  119.  
  120.                 Dim arg As TypeCode = myArgs(0).Typecode
  121.  
  122.                 If arg = LispDataType.T_atom Then
  123.                     If My.Computer.Keyboard.NumLock <> True Then
  124.                         ToggleNumLock()
  125.                     End If
  126.                     Return True
  127.                 End If
  128.  
  129.                 If arg = LispDataType.Nil Then
  130.                     If My.Computer.Keyboard.NumLock <> False Then
  131.                         ToggleNumLock()
  132.                     End If
  133.                     Return Nothing
  134.                 End If
  135.  
  136.                 Throw New ArgumentTypeException("atom", myArgs(0))
  137.                 Return Nothing
  138.  
  139.             Catch ex As LispException
  140.                 ed.WriteMessage(vbLf & "LISP error: {0}" & vbLf, ex.Message)
  141.                 Return Nothing
  142.  
  143.             Catch ex As Autodesk.AutoCAD.Runtime.Exception
  144.                 ed.WriteMessage(vbLf & "AutoCAD error: {0}" & vbLf, ex.Message)
  145.                 Return Nothing
  146.  
  147.             Catch ex As System.Exception
  148.                 ed.WriteMessage(vbLf & "System error: {0}" & vbLf, ex.Message)
  149.                 Return Nothing
  150.  
  151.             End Try
  152.  
  153.         End Function
  154.  
  155. #End Region
  156.  
  157. #Region "ScrollLock"
  158.  
  159.         Shared Sub ToggleScrollLock()
  160.             keybd_event(System.Windows.Forms.Keys.Scroll, &H91, 1, 0)
  161.             keybd_event(System.Windows.Forms.Keys.Scroll, &H91, 3, 0)
  162.         End Sub
  163.  
  164.         <LispFunction("ScrollLock")> _
  165.         Public Function ScrollLock(ByVal args As ResultBuffer)
  166.             Try
  167.                 If args Is Nothing Then
  168.                     If My.Computer.Keyboard.ScrollLock = True Then
  169.                         Return True
  170.                     Else
  171.                         Return Nothing
  172.                     End If
  173.                 End If
  174.  
  175.                 Dim myArgs As Array = args.AsArray
  176.  
  177.                 If myArgs.Length > 1 Then
  178.                     Throw New TooManyArgsException()
  179.                 End If
  180.  
  181.                 Dim arg As TypeCode = myArgs(0).Typecode
  182.  
  183.                 If arg = LispDataType.T_atom Then
  184.                     If My.Computer.Keyboard.ScrollLock <> True Then
  185.                         ToggleScrollLock()
  186.                     End If
  187.                     Return True
  188.                 End If
  189.  
  190.                 If arg = LispDataType.Nil Then
  191.                     If My.Computer.Keyboard.ScrollLock <> False Then
  192.                         ToggleScrollLock()
  193.                     End If
  194.                     Return Nothing
  195.                 End If
  196.  
  197.                 Throw New ArgumentTypeException("atom", myArgs(0))
  198.                 Return Nothing
  199.  
  200.             Catch ex As LispException
  201.                 ed.WriteMessage(vbLf & "LISP error: {0}" & vbLf, ex.Message)
  202.                 Return Nothing
  203.  
  204.             Catch ex As Autodesk.AutoCAD.Runtime.Exception
  205.                 ed.WriteMessage(vbLf & "AutoCAD error: {0}" & vbLf, ex.Message)
  206.                 Return Nothing
  207.  
  208.             Catch ex As System.Exception
  209.                 ed.WriteMessage(vbLf & "System error: {0}" & vbLf, ex.Message)
  210.                 Return Nothing
  211.  
  212.             End Try
  213.  
  214.         End Function
  215.  
  216. #End Region
  217.  
  218. #Region "VolumeMute"
  219.  
  220.         ' More to come
  221.  
  222. #End Region
  223.  
  224.     End Class
  225.  
  226. #End Region
  227.  
  228. #Region "myExceptions"
  229.  
  230.     ''' <summary>
  231.     ''' Special thanks to Gile for help with 'LispExceptions'
  232.     ''' More info here: http://www.theswamp.org/index.php?topic=41509.msg466232#msg466232
  233.     ''' </summary>
  234.     ''' <remarks></remarks>
  235.     Public Class LispException
  236.         Inherits System.Exception
  237.  
  238.         Public Sub New(ByVal msg As String)
  239.             MyBase.New(msg)
  240.  
  241.         End Sub
  242.  
  243.     End Class
  244.  
  245.  
  246.     Public Class TooFewArgsException
  247.         Inherits LispException
  248.  
  249.         Public Sub New()
  250.             MyBase.New("Too few arguments")
  251.  
  252.         End Sub
  253.  
  254.     End Class
  255.  
  256.  
  257.     Public Class TooManyArgsException
  258.         Inherits LispException
  259.  
  260.         Public Sub New()
  261.             MyBase.New("Too many arguments")
  262.  
  263.         End Sub
  264.  
  265.     End Class
  266.  
  267.  
  268.     Public Class ArgumentTypeException
  269.         Inherits LispException
  270.  
  271.         Public Sub New(ByVal s As String, ByVal tv As TypedValue)
  272.             MyBase.New(String.Format("Bad argument type: {0} {1}", s, (tv.TypeCode = CType(LispDataType.Nil, Integer))))
  273.  
  274.         End Sub
  275.  
  276.     End Class
  277.  
  278. #End Region
  279.  
  280. End Namespace
  281.  
« Last Edit: August 17, 2012, 10:21:13 AM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Caps Lock
« Reply #21 on: April 11, 2012, 10:31:59 AM »
@ RenderMan

Works great thanks for the help.  It's a great resource for a lisper.  :mrgreen:
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

BlackBox

  • King Gator
  • Posts: 3770
Re: Caps Lock
« Reply #22 on: April 11, 2012, 10:37:20 AM »
@ RenderMan

Works great thanks for the help.  It's a great resource for a lisper.  :mrgreen:

That is kind of you to say, and you're welcome, Tim.   :kewl:
"How we think determines what we do, and what we do determines what we get."

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Caps Lock
« Reply #23 on: April 11, 2012, 03:00:33 PM »
I'm going to try to use this as a reactor for editing attributes to make sure caps are on.  so.    uh.       look out.
Just wanted to post my light bulb moment.

*EDIT*
It would be great to use in a reactor for text and such

Just wanted to RE-post Tims light bulb moment.
I'm always a little too late.
Too late, too late <-anybody get the song reference? it's obscure....
« Last Edit: April 11, 2012, 03:04:49 PM by Dommy2Hotty »

BlackBox

  • King Gator
  • Posts: 3770
Re: Caps Lock
« Reply #24 on: April 11, 2012, 03:08:41 PM »
Interesting... I can certainly understand why some would like to retain CapsLock = ON while working within AutoCAD, but I am curious as to what Event you're going to monitor on which to trigger your CallBack of (CapsLock T)...?  :?

Having not tested this myself (yet) obviously, I wonder just how 'taxed' the Environment would be if one were to use something basic, like a CommandReactor... Pseudo CallBack:

Code - Auto/Visual Lisp: [Select]
  1. ;;; CommandWillStart Event
  2. (defun CallBack:CapsLockTest (rea cmd / )
  3.   (if (not (CapsLock))
  4.     (CapsLock T))
  5.  
  6.   ;; <-- More
  7.   )
  8.  

... This is definitely something to tinker with after work.

** Edit - I wonder if there's something useful in either Grread, or vlr-Window-Reactor (for maintaining CapsLock = ON in AutoCAD, and OFF when in another application)...?
« Last Edit: April 18, 2012, 01:18:13 PM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Caps Lock
« Reply #25 on: April 11, 2012, 03:53:37 PM »
I think using the command reactor will work fine.  I use one now for "grip_stretch" and it seems to work great.  I don;t have time to pen anything today but I will tomorrow.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Caps Lock
« Reply #26 on: April 11, 2012, 04:04:53 PM »
Just thought I'd throw this out there.   :roll:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

BlackBox

  • King Gator
  • Posts: 3770
Re: Caps Lock
« Reply #27 on: April 11, 2012, 04:06:42 PM »
 :lmao:
"How we think determines what we do, and what we do determines what we get."

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Caps Lock
« Reply #28 on: April 12, 2012, 07:46:47 AM »
Looks like Neil Fallon (lead singer from Clutch).
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Caps Lock
« Reply #29 on: April 12, 2012, 09:54:06 AM »
Here is a command reactor for the caps lock.  If anyone can think of other commands that may apply let me know.

**EDIT - MODIFIED ATTACHMENT**
« Last Edit: April 12, 2012, 10:56:39 AM by TimSpangler »
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016