Author Topic: Keyboard hook?  (Read 3258 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Keyboard hook?
« on: January 17, 2010, 11:32:01 PM »
Is it possible to do a keyboard hook in VBA?  I don't know much of anything about VBA programming, and I'm not finding much online to answer the question.  Sample code would be really, really helpful.  I'm looking at the possibility of making this code  http://www.theswamp.org/index.php?topic=25412.0   work in Bricscad, but the GRREAD function in Bricscad returns codes for the arrow keys which are identical to the characters %, &, (, and ' so I get mangled text rather than cursor control.  I'm thinking that if there is a way to hook the keyboard and stuff the actual scan codes into variables that could be accessed by lisp it would open a lot of possibilities.  The concept is to have a VBA function to set a keyboard hook right before running the keyboard entry loop, then unload the VBA as soon as the lisp is done.  I've looked at Autohook and AutoIT but neither seems right for this.  Any help or suggestions appreciated.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

Chuck Gabriel

  • Guest
Re: Keyboard hook?
« Reply #1 on: January 18, 2010, 09:23:15 AM »
I tried it years ago, and couldn't get it to work.  I'll post some code here in a bit if I can find it.  I seem to recall that it is possible to subclass the AutoCAD window from VBA.

By way of warning, this is fairly advanced stuff with a lot of pitfalls for somebody who, by their own admission, doesn't know much about VBA.

Chuck Gabriel

  • Guest
Re: Keyboard hook?
« Reply #2 on: January 18, 2010, 09:47:38 AM »
Here is the code I promised, and apparently I remembered incorrectly.  I does seem to work.  It doesn't do exactly what you need though, and it is VB6, not VBA.  Still, it should give you some idea of how to insert a keyboard hook.

hmspe

  • Bull Frog
  • Posts: 362
Re: Keyboard hook?
« Reply #3 on: January 18, 2010, 12:44:07 PM »
Thanks.  I'll see what I can do with it.
"Science is the belief in the ignorance of experts." - Richard Feynman