Reactor not firing... but why?

Reactor not firing... but why?

Anonymous
Not applicable
1,815 Views
10 Replies
Message 1 of 11

Reactor not firing... but why?

Anonymous
Not applicable

Hello,

 

The Story...

I have a few users asking if there is a way to have caps lock go on and off automatically when they switch between windows. Example: A user is typing an Email using the normal sentence case (CAPS Lock off) and then they switch to AutoCAD and add some MText which, for our firm, should be all caps. For some reason, they need to go back to the Email and want it back in lowercase. I hope that makes sense. When in AutoCAD, all caps, in any other window, lowercase.

Yes, I know you can set MText to be all caps and that's great but what about block attributes, tables, and/or DText which we use from time to time.


Anyway, I decided that a reactor would fit this bill. The vlr-docmanager-reactor to be exact because it has documentToBeActivated and documentToBeDeactivated events. I am also using DOSLib to facilitate the turning on/off of the CAPS Lock key -> (dos_capslock T) [ ON ] (dos_capslock) [ OFF ]. So this appears to be very simple.

When documentToBeActivated is fired, turn CAPS Lock on.

When doucmentToBeDeactivated is fired, turn CAPS Lock off.

Simple right?

Well, it's not working for me.

Here's the code I have. It's saved in a file named ACADAllCaps.lsp which I'm going to either drop in the startup suite or load via acaddoc.lsp or acad.lsp.

 

(vl-load-com)

 

(vlr-docmanager-reactor nil '((:vlr-documentToBeActivated . turncapson)))
(vlr-docmanager-reactor nil '((:vlr-documentToBeDeactivated . turncapsoff)))

 

(defun turncapson (calling-reactor docstatus / )
(dos_capslock t)
(prompt "CAPS Lock should be ON.")
(princ)
)

 

(defun turncapsoff (calling-reactor docstatus / )
(dos_capslock)
(prompt "CAPS Lock should be OFF.")
(princ)
)

 

I have the prompt statements in there to let me know if the functions fire and I haven't seen them yet. Oh, and the CAPS Lock light hasn't gone on/off either, so...

I based this off of what I read about reactors from afralisp.com which was very informative.

 

Please review and let me know what I'm missing. I'm sure it's something really stupid but that is escaping me now. Smiley Very Happy

 

Thank you in advance for your help.

Mb

0 Likes
Accepted solutions (1)
1,816 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

AFAIK the documentToBeActivated/documentToBeDeactivated reactor works at document level. So if you are switching between documents in the same application object, the reactor will monitor a documents status. It does not, however, work at the application level. If you are switching between AutoCAD and some other application it won't work. Maybe try the .Net forum.

Another option would be to setup a reactor to monitor when, for instance, Mtext command is invoked and check if capslock is on.

Message 3 of 11

Anonymous
Not applicable

Thanks for the insight and I thought that might be the issue.

I realized it was the document object and not the application object but figured that if you switch focus from one window to another it would be deactivated/activated. I guess that isn't the case.

So, there are no application reactors?

Bummer.

 

Thanks again, I'll see if there is another way.

0 Likes
Message 4 of 11

john.uhden
Mentor
Mentor

How about using a vlr-editor reactor and vlr-commandWillStart?

 

That way any command can turn capslock on.  If you want, you can turn it off when vlr-commandEnded or Cancelled or Failed.

Of course that doesn't help when the user switches to another app in the middle of a commmand, but it may be better than nothing.

John F. Uhden

0 Likes
Message 5 of 11

dbroad
Mentor
Mentor
Accepted solution

Have you tried setting TEXTALLCAPS to ON?  No reactor required.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 6 of 11

john.uhden
Mentor
Mentor
How would I know about that one?!

John F. Uhden

0 Likes
Message 7 of 11

Anonymous
Not applicable

W O W....

 

So simple.

Now the question is, why didn't that come up in any of my searches.

 

Thanks so much and YES, that IS much easier than a reactor.

I actually got it to work (for the most part) using VBA. But this is so much easier.

 

I bow to your brilliance.

 

Mb

0 Likes
Message 8 of 11

dbroad
Mentor
Mentor

@Anonymous:  You're welcome.

 

@john.uhden:  Keep an eye on the results when keying in commands.  I found it by accident myself.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 9 of 11

john.uhden
Mentor
Mentor
You should know that I was referring to 2002. 😕

John F. Uhden

0 Likes
Message 10 of 11

dbroad
Mentor
Mentor

@john.uhden:  Condolences. The versions since have added lots of handy improvements. I'm on 2017. If that info was on your signature, note that I usually keep the signatures suppressed on this site since some signatures are often many times longer than the messages and often don't make sense in context.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 11 of 11

john.uhden
Mentor
Mentor

I am not using any signature.  Those days have long faded away.

John F. Uhden

0 Likes