Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Keyboard Hook

Status
Not open for further replies.

RMS001

Programmer
Nov 12, 2002
45
CA
Hi

There must be a way to intercept the Virtual keys
before the system sends them to your control or form.

'KeyPreview = True' does not go far enough.

You could put GetAsyncKeyState in a loop, but isn't
that a step backwards?

Windows is so layered compared to DOS C++ and Assembler,
I am having trouble adjusting...
 
There's exactly what you mentioned in the subjec of your post... a keyboard hook.

Check out SetWindowsHookEx for that.


Greetings,
Rick
 
Hi Rick - You have been a big help already!

SetWindowsHookEx is not covered in Appleman

Since his volume is getting old now, do you
know of a newer publication that would
supercede his book?

Or, a place to get the information on how to use
this API

-Ron
 

as lazyme said its not too vb friendly, but hey!! you also get related hook apis down the left

for declares, johnwm's link is perty good!!

but just in case...

Private Declare Function SetWindowsHook Lib "user32" Alias "SetWindowsHookA" (ByVal nFilterType As Long, ByVal pfnFilterProc As Long) As Long

Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long

i also saw a worked example (on expert exchange or developer fusion or somewhere), a quick google search just bring up some decent code hits though

good luck!!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
First, LazyMe

MSDN did the trick – THANX Rick!

(I would post the code, but the caveats are worth reading
so I’ll let others go there too: Article ID: Q177992)


Second, johnwm

is a fantastic site.

THANX for that!

Code similar to MSDN can be found there.

I did check for previous threads before posting.
The link FAQ222-2244 just goes to the main page (no info).


Third, Adoozer

It never occurred to me do a search for a specific API.
It brought up johnwn’s site and some other interesting stuff.

Good idea!


Thank you all so much for the help. It is such a good place
to get info; the site is very user friendly.

I don’t have much to offer in return, but if you ever want
to use DOS to read the wires right off the keyboard,
I have written a program in C which uses a small Assembler
routine to read the keyboard port directly. No? I thought not.


…and Confucius replied, “Who the hell is Murphy?”
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top