Global Key trapping
Hi again
Does anyone have any idea / experience of writing a VB app that will catch a certain key press i.e. Alt F12, from ANY WINDOWS.
i.e. All VB forms are HIDDEN and waiting for the key press to open up
I was thinking that maybe and ActiveX .dll that the hidden vb app kicked off, would sit there waiting for key press, and if it found it it would then open up the hidden forms and pass data to them.
Is this possible or is it the realms of VB.Net or C#
Thanks again
Xena
[528 byte] By [
Xena] at [2007-11-17 17:07:33]

# 1 Re: Global Key trapping
You can use the sub "form_keydown(keycode ......)" instate of "form_keypress"
something like this:
private sub form_keydown(keycode......)
if keycode = vbkeyF1 then form2.show
if keycode = vbkeyF2 then form3.show
if keycode = vbkeyF3 then form4.show
end sub
You can also work with the API function getkeystate, that is a little bit difficultier, but works better.
# 2 Re: Global Key trapping
Yeah...I get that.
But it only works when you have an OPEN and FOCUS'D VB form running.
I'm trying to have ALL, EVERY vb FORM HIDDEN.
And yet STILL waiting for a key trap.
After playing around with ActiveX .exe's and .dll's I believe now, that's NOT the way to go.
Yes, I have found some API calls, but again I'm faced with the fact that at least on of the VB forms has to be OPEN and FOCUS'D in order to 'trap' the keypress.
It's like applications that sit in the System Tray. Some of those 'wait' for a keypress.
Surely you can write those in VB 6?
That's the same kind of funtionality that I'm trying to get.
Anymore thoughts anyone?
X
Xena at 2007-11-10 0:23:45 >

# 3 Re: Global Key trapping
http://www.allapi.net/apilist/apifunction.php?apifunction=SetWindowsHookEx
Note for parameters
lpfn
Points to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
pekko at 2007-11-10 0:24:47 >
