How can I know the Caps Lock is on/off by lisp

How can I know the Caps Lock is on/off by lisp

Anonymous
Not applicable
1,796 Views
17 Replies
Message 1 of 18

How can I know the Caps Lock is on/off by lisp

Anonymous
Not applicable

Hello. How can I know the Caps Lock is on/off by lisp?

0 Likes
Accepted solutions (1)
1,797 Views
17 Replies
Replies (17)
Message 2 of 18

hak_vz
Advisor
Advisor

You can not do this directly, but you can use  DOSLIB 

(dos_capslock 1) = on
(dos_capslock) = off

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 18

Sea-Haven
Mentor
Mentor

Why ? If a problem of case there are change case code out there or in a IF use (case str) forces caps.

0 Likes
Message 4 of 18

Anonymous
Not applicable

thank you.

Is that set up?  If I jist want know the status on/off.How can I do?

0 Likes
Message 5 of 18

Anonymous
Not applicable

I want to control a lisp to work on or not. For example. If Caps Lock is on,the plug-in unit dosen't work.

0 Likes
Message 6 of 18

Sea-Haven
Mentor
Mentor

If its open code then the CASE function should fix the problem.

0 Likes
Message 7 of 18

Anonymous
Not applicable

thank you.examples

0 Likes
Message 8 of 18

hak_vz
Advisor
Advisor

@Anonymous 

If you know some autolisp it easy to do. I have pointed out name of the function you should use.

Download DOSLIB, and create something. I don't use it lately and have no time to write examples, but you can certainly find a lot of examples by simply googling for "autolisp doslib".

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 9 of 18

Anonymous
Not applicable

thanks.I'll learn it .It's useful & helpful.

0 Likes
Message 10 of 18

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

I want to control a lisp to work on or not. For example. If Caps Lock is on,the plug-in unit dosen't work.


Here's a routine I ran across some time ago, that I have used to force Caps-lock on when I start up AutoCAD [via acaddoc.lsp], which you may be able to modify to force it off.  It works through MS Word.

;; Turn Caps Lock on: [edited from Tim Spangler in "Caps Lock," theswamp.org 04/09/12]
(setq
  isMSW (vlax-get-object "Word.Application"); nil if Word not running already
  MSW (vlax-get-or-create-object "Word.Application"); whether or not already
); setq
(if (= (vlax-get MSW 'CapsLock) 0); Caps Lock is off
  (vlax-invoke-method
    (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell")
    'SendKeys "{CAPSLOCK}"
  ); -invoke
); if
(if (not isMSW) (vlax-invoke-method MSW 'quit)); Exit Word only if not otherwise in use
(vlax-release-object MSW)

 

Kent Cooper, AIA
Message 11 of 18

Anonymous
Not applicable

Thank you very mach.I have tried it and It's good.Muth computers have MS Word.

0 Likes
Message 12 of 18

Sea-Haven
Mentor
Mentor

i FOUND THIS, (acet-sys-keystate 20) it returns 0 or 1 for on / off. Acet is part of express tools and works in Bricscad.

 

20 is capslock

Message 13 of 18

diagodose2009
Collaborator
Collaborator

You transform your-programe to programe_jc10aro.lsp. All calls from original source will be redirected

to one caller named (jc_aro10 "name-of-function" )..

The main tricks, you can insert the 

Command: (acet-sys-keystate 20)

(acet-sys-keystate 20) as function. When the capslock=1 entire program, has be stopped.

Please you insert the "(acet-sys-keystate 20)" inside (defun jc_aro10...........

 

 

0 Likes
Message 14 of 18

TomBeauford
Advisor
Advisor

To make sure Caps Lock is off

(if(=(acet-sys-keystate 20)1)(vlax-invoke-method (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell") 'SendKeys "{CAPSLOCK}"))

To make sure Caps Lock is on

(if(=(acet-sys-keystate 20)0)(vlax-invoke-method (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell") 'SendKeys "{CAPSLOCK}"))

 

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
Message 15 of 18

TomBeauford
Advisor
Advisor

Just for fun

To make sure Num Lock is off

 

(if(=(acet-sys-keystate 144)1)(vlax-invoke-method (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell") 'SendKeys "{NUMLOCK}"))

 

To make sure Num Lock is on

 

(if(=(acet-sys-keystate 144)0)(vlax-invoke-method (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell") 'SendKeys "{NUMLOCK}"))

Keyboard Key Code Values

 

https://www.oreilly.com/library/view/javascript-dhtml/9780596514082/apb.html

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 16 of 18

john.uhden
Mentor
Mentor

@Anonymous 

That's a noble idea, but capslock can be on or off and the user can hold down the shift key, so you cannot control the raw input.  I think that with using grread you can make the user feel as though the case is out of their control, but you can't use grread within a dialog box or other standard AutoCAD input dialogs.

John F. Uhden

0 Likes
Message 17 of 18

Anonymous
Not applicable

Thank you very much for your reply. My friend asked me to make a reactor plug-in for him, but sometimes he don't use it. So he want to use a switch to control whether the reactor works, and specify to use the cap lock key to control it.Is there a better way?

0 Likes
Message 18 of 18

john.uhden
Mentor
Mentor
You've made me think that a command-reactor might be what you want. It
could be set up to take action on the start of only certain commands
thereby allowing the reaction to turn capslock on or off before the user
provides any input.

John F. Uhden

0 Likes