How do I trapp Key-press event outside my form
Hi
Have a look at setting up a KeyboardProc with the AddressOf, I think it is a
system wide.
Look on MSDN under KeyboardProc or WH_KEYBOARD.
Regards
Neal
"sanjiv" <sanjiv@england.com> wrote in message
news:38d337b1$1@news.dev-archive.com...
>
> Hi,
> I want to trapp key_press event out side my form.I just want to
> know about each key_keypress while my application is running(even outside
> my application)
> I will be thanking you all.
>
> Regards
>
> Sanjiv
# 1 Re: How do I trapp Key-press event outside my form
Hi
Have a look at setting up a KeyboardProc with the AddressOf, I think it is a
system wide.
Look on MSDN under KeyboardProc or WH_KEYBOARD.
Regards
Neal
"sanjiv" <sanjiv@england.com> wrote in message
news:38d337b1$1@news.dev-archive.com...
>
> Hi,
> I want to trapp key_press event out side my form.I just want to
> know about each key_keypress while my application is running(even outside
> my application)
> I will be thanking you all.
>
> Regards
>
> Sanjiv
# 2 Re: How do I trapp Key-press event outside my form
Hi,
I want to trapp key_press event out side my form.I just want to
know about each key_keypress while my application is running(even outside
my application)
I will be thanking you all.
Regards
Sanjiv
sanjiv at 2007-11-11 20:05:33 >

# 3 Re: How do I trapp Key-press event outside my form
This is not possible with VB alone. You will need Spyworks, or something similar
(or C)
"sanjiv" <sanjiv@england.com> wrote:
>
>Hi,
>I want to trapp key_press event out side my form.I just want to
>know about each key_keypress while my application is running(even outside
>my application)
>I will be thanking you all.
>
>Regards
>
>Sanjiv
Mike at 2007-11-11 20:06:32 >

# 4 Re: How do I trapp Key-press event outside my form
This is not possible with VB alone. You will need Spyworks, or something similar
(or C)
"sanjiv" <sanjiv@england.com> wrote:
>
>Hi,
>I want to trapp key_press event out side my form.I just want to
>know about each key_keypress while my application is running(even outside
>my application)
>I will be thanking you all.
>
>Regards
>
>Sanjiv
Mike at 2007-11-11 20:07:32 >

# 5 Re: How do I trapp Key-press event outside my form
sanjiv,
: I want to trapp key_press event out side my form.I just want to
: know about each key_keypress while my application is running(even outside
: my application)
It looks like you want a keyboard hook. I have a sample (with VB code) at
http://members.xoom.com/damit/keyhook.zip and I'm quite sure that there are
other people with samples...
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 6 Re: How do I trapp Key-press event outside my form
sanjiv,
: I want to trapp key_press event out side my form.I just want to
: know about each key_keypress while my application is running(even outside
: my application)
It looks like you want a keyboard hook. I have a sample (with VB code) at
http://members.xoom.com/damit/keyhook.zip and I'm quite sure that there are
other people with samples...
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 7 Re: How do I trapp Key-press event outside my form
Neal,
The keyboard hook that can be used through VB is not system wide, only app
wide. So when you app loses focus you get no keyboard events.
Damit's example uses a C dll, but it didn't work properly on my machine.
(maybe it doesn't like NT)
Mike
"Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>Hi
>Have a look at setting up a KeyboardProc with the AddressOf, I think it
is a
>system wide.
>Look on MSDN under KeyboardProc or WH_KEYBOARD.
>Regards
>
>Neal
>
>"sanjiv" <sanjiv@england.com> wrote in message
>news:38d337b1$1@news.dev-archive.com...
>>
>> Hi,
>> I want to trapp key_press event out side my form.I just want to
>> know about each key_keypress while my application is running(even outside
>> my application)
>> I will be thanking you all.
>>
>> Regards
>>
>> Sanjiv
>
>
Mike at 2007-11-11 20:10:44 >

# 8 Re: How do I trapp Key-press event outside my form
Neal,
The keyboard hook that can be used through VB is not system wide, only app
wide. So when you app loses focus you get no keyboard events.
Damit's example uses a C dll, but it didn't work properly on my machine.
(maybe it doesn't like NT)
Mike
"Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>Hi
>Have a look at setting up a KeyboardProc with the AddressOf, I think it
is a
>system wide.
>Look on MSDN under KeyboardProc or WH_KEYBOARD.
>Regards
>
>Neal
>
>"sanjiv" <sanjiv@england.com> wrote in message
>news:38d337b1$1@news.dev-archive.com...
>>
>> Hi,
>> I want to trapp key_press event out side my form.I just want to
>> know about each key_keypress while my application is running(even outside
>> my application)
>> I will be thanking you all.
>>
>> Regards
>>
>> Sanjiv
>
>
Mike at 2007-11-11 20:11:36 >

# 9 Re: How do I trapp Key-press event outside my form
Mike,
: Damit's example uses a C dll, but it didn't work properly on my machine.
: (maybe it doesn't like NT)
Actually, I developed the DLL on NT4/Win2000, so it shouldn't be liking 98.
:-)
(obvious question) Did you remember to change the paths? Also, did you get
an error message, GPF, or something similar? Finally, is your callback
function declared like the one in the example? (It definitely has to be...)
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 10 Re: How do I trapp Key-press event outside my form
Mike,
: Damit's example uses a C dll, but it didn't work properly on my machine.
: (maybe it doesn't like NT)
Actually, I developed the DLL on NT4/Win2000, so it shouldn't be liking 98.
:-)
(obvious question) Did you remember to change the paths? Also, did you get
an error message, GPF, or something similar? Finally, is your callback
function declared like the one in the example? (It definitely has to be...)
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 11 Re: How do I trapp Key-press event outside my form
Damit,
I am using your example. As my D Drive is a cd-rom, I changed the path to
c:\projects etc. It all works OK, it traps keypresses, but once I switch
to any other app, or the desktop, it stops trapping keypresses. When I return
to the app it still does not trap keypresses unless I push unload and load.
I have tried it on 2 NT machines, one with SP5 and one with SP6, and got
the same result. I don't get any errors, GPFs etc, except for the Path Not
Found before I changed the path. I am using VB6 SP3.
Any suggestions?
Mike
"Damit Senanayake" <damit@mvps.org> wrote:
>Mike,
>
>: Damit's example uses a C dll, but it didn't work properly on my machine.
>: (maybe it doesn't like NT)
>
>Actually, I developed the DLL on NT4/Win2000, so it shouldn't be liking
98.
>:-)
>
>(obvious question) Did you remember to change the paths? Also, did you get
>an error message, GPF, or something similar? Finally, is your callback
>function declared like the one in the example? (It definitely has to be...)
>
>--
>Damit Senanayake | damit@mvps.org
>Please reply to newsgroups, not by e-mail.
>http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
>ICQ: 6930718
>
>
Mike at 2007-11-11 20:14:47 >

# 12 Re: How do I trapp Key-press event outside my form
Damit,
I am using your example. As my D Drive is a cd-rom, I changed the path to
c:\projects etc. It all works OK, it traps keypresses, but once I switch
to any other app, or the desktop, it stops trapping keypresses. When I return
to the app it still does not trap keypresses unless I push unload and load.
I have tried it on 2 NT machines, one with SP5 and one with SP6, and got
the same result. I don't get any errors, GPFs etc, except for the Path Not
Found before I changed the path. I am using VB6 SP3.
Any suggestions?
Mike
"Damit Senanayake" <damit@mvps.org> wrote:
>Mike,
>
>: Damit's example uses a C dll, but it didn't work properly on my machine.
>: (maybe it doesn't like NT)
>
>Actually, I developed the DLL on NT4/Win2000, so it shouldn't be liking
98.
>:-)
>
>(obvious question) Did you remember to change the paths? Also, did you get
>an error message, GPF, or something similar? Finally, is your callback
>function declared like the one in the example? (It definitely has to be...)
>
>--
>Damit Senanayake | damit@mvps.org
>Please reply to newsgroups, not by e-mail.
>http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
>ICQ: 6930718
>
>
Mike at 2007-11-11 20:15:44 >

# 13 Re: How do I trapp Key-press event outside my form
Hi Mike,
: When I return
: to the app it still does not trap keypresses unless I push unload and
load.
: I have tried it on 2 NT machines, one with SP5 and one with SP6, and got
: the same result.
OK, I can reproduce this over here too... probably during testing I didn't
verify switching away from the window and then switching back to it :-( I'll
try and investigate this problem further, though.
Can you verify whether this occurs on a 9x system?
Also, if you're targeting NT only, you may want to look at a low-level
keyboard hook (WH_KEYBOARD_LL) - this supposedly traps even keybd_event()
calls...
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 14 Re: How do I trapp Key-press event outside my form
Hi Mike,
: When I return
: to the app it still does not trap keypresses unless I push unload and
load.
: I have tried it on 2 NT machines, one with SP5 and one with SP6, and got
: the same result.
OK, I can reproduce this over here too... probably during testing I didn't
verify switching away from the window and then switching back to it :-( I'll
try and investigate this problem further, though.
Can you verify whether this occurs on a 9x system?
Also, if you're targeting NT only, you may want to look at a low-level
keyboard hook (WH_KEYBOARD_LL) - this supposedly traps even keybd_event()
calls...
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 15 Re: How do I trapp Key-press event outside my form
Mike and all,
I've posted a new version which, according to my testing, fixes the bug that
Mike mentioned. The URL is still the same -
http://members.xoom.com/damit/keyhook.zip
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 16 Re: How do I trapp Key-press event outside my form
Mike and all,
I've posted a new version which, according to my testing, fixes the bug that
Mike mentioned. The URL is still the same -
http://members.xoom.com/damit/keyhook.zip
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 17 Re: How do I trapp Key-press event outside my form
>OK, I can reproduce this over here too... probably during testing I didn't
>verify switching away from the window and then switching back to it :-(
I'll
>try and investigate this problem further, though.
Wasn't the idea of the dll so that VB could pick up keystrokes when it didn't
have the focus?
I tried it in win95. Every time I switched to another app and pushed a key,
that app crashed. This was a fresh install of win95B with only VB5 (SP3)
on it.
Mike
Mike at 2007-11-11 20:20:54 >

# 18 Re: How do I trapp Key-press event outside my form
>OK, I can reproduce this over here too... probably during testing I didn't
>verify switching away from the window and then switching back to it :-(
I'll
>try and investigate this problem further, though.
Wasn't the idea of the dll so that VB could pick up keystrokes when it didn't
have the focus?
I tried it in win95. Every time I switched to another app and pushed a key,
that app crashed. This was a fresh install of win95B with only VB5 (SP3)
on it.
Mike
Mike at 2007-11-11 20:21:47 >

# 19 Re: How do I trapp Key-press event outside my form
Hi Mike,
: Wasn't the idea of the dll so that VB could pick up keystrokes when it
didn't
: have the focus?
No, actually - the DLL is required because this is a system-wide hook, and
hence must be loaded into every process that uses user32.dll (i.e. it has to
be a DLL), and has nothing to do with VB having the focus or otherwise.
But when I tested it, I didn't consider that it might not work when the app
didn't have the focus - but try the new version; I extensively tested
switching the focus away from and to the app.
: I tried it in win95. Every time I switched to another app and pushed a
key,
: that app crashed. This was a fresh install of win95B with only VB5 (SP3)
: on it.
Which app crashed? The one that you switched to? Again, can you verify this
with the latest build (same URL)?
If you can't let me know and I'll test it out myself on Win98.
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 20 Re: How do I trapp Key-press event outside my form
Hi Mike,
: Wasn't the idea of the dll so that VB could pick up keystrokes when it
didn't
: have the focus?
No, actually - the DLL is required because this is a system-wide hook, and
hence must be loaded into every process that uses user32.dll (i.e. it has to
be a DLL), and has nothing to do with VB having the focus or otherwise.
But when I tested it, I didn't consider that it might not work when the app
didn't have the focus - but try the new version; I extensively tested
switching the focus away from and to the app.
: I tried it in win95. Every time I switched to another app and pushed a
key,
: that app crashed. This was a fresh install of win95B with only VB5 (SP3)
: on it.
Which app crashed? The one that you switched to? Again, can you verify this
with the latest build (same URL)?
If you can't let me know and I'll test it out myself on Win98.
--
Damit Senanayake | damit@mvps.org
Please reply to newsgroups, not by e-mail.
http://members.xoom.com/damit | {http,ftp}://damit.dyndns.org (experimental)
ICQ: 6930718
# 21 Re: How do I trapp Key-press event outside my form
What A great psc of code, However is the reporting of extended key correct?
On windows NT 4 SP5 all the numkeys and Fx keys are displaying as not extended.
Or maybe it does not deciefer this correctly.
Any ides ?
Des
"Mike" <m_culley@one.net.au> wrote:
>
>>OK, I can reproduce this over here too... probably during testing I didn't
>>verify switching away from the window and then switching back to it :-(
>I'll
>>try and investigate this problem further, though.
>
>Wasn't the idea of the dll so that VB could pick up keystrokes when it didn't
>have the focus?
>
>I tried it in win95. Every time I switched to another app and pushed a key,
>that app crashed. This was a fresh install of win95B with only VB5 (SP3)
>on it.
>
>Mike
Des at 2007-11-11 20:24:52 >

# 22 Re: How do I trapp Key-press event outside my form
What A great psc of code, However is the reporting of extended key correct?
On windows NT 4 SP5 all the numkeys and Fx keys are displaying as not extended.
Or maybe it does not deciefer this correctly.
Any ides ?
Des
"Mike" <m_culley@one.net.au> wrote:
>
>>OK, I can reproduce this over here too... probably during testing I didn't
>>verify switching away from the window and then switching back to it :-(
>I'll
>>try and investigate this problem further, though.
>
>Wasn't the idea of the dll so that VB could pick up keystrokes when it didn't
>have the focus?
>
>I tried it in win95. Every time I switched to another app and pushed a key,
>that app crashed. This was a fresh install of win95B with only VB5 (SP3)
>on it.
>
>Mike
Des at 2007-11-11 20:25:57 >

# 23 Re: How do I trapp Key-press event outside my form
KeyboardProc is system wide but you must use 13 as the ID of the hook!
However it doesn't get system keys, I can't get lowlevelkeyboardProc to work,
anyone can? In VB that is, in C++ its a doddle.
C
"Mike" <m_culley@one.net.au> wrote:
>
>Neal,
>
>The keyboard hook that can be used through VB is not system wide, only app
>wide. So when you app loses focus you get no keyboard events.
>
>Damit's example uses a C dll, but it didn't work properly on my machine.
>(maybe it doesn't like NT)
>
>Mike
>
>"Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>>Hi
>>Have a look at setting up a KeyboardProc with the AddressOf, I think it
>is a
>>system wide.
>>Look on MSDN under KeyboardProc or WH_KEYBOARD.
>>Regards
>>
>>Neal
>>
>>"sanjiv" <sanjiv@england.com> wrote in message
>>news:38d337b1$1@news.dev-archive.com...
>>>
>>> Hi,
>>> I want to trapp key_press event out side my form.I just want to
>>> know about each key_keypress while my application is running(even outside
>>> my application)
>>> I will be thanking you all.
>>>
>>> Regards
>>>
>>> Sanjiv
>>
>>
>
Cian at 2007-11-11 20:26:57 >

# 24 Re: How do I trapp Key-press event outside my form
KeyboardProc is system wide but you must use 13 as the ID of the hook!
However it doesn't get system keys, I can't get lowlevelkeyboardProc to work,
anyone can? In VB that is, in C++ its a doddle.
C
"Mike" <m_culley@one.net.au> wrote:
>
>Neal,
>
>The keyboard hook that can be used through VB is not system wide, only app
>wide. So when you app loses focus you get no keyboard events.
>
>Damit's example uses a C dll, but it didn't work properly on my machine.
>(maybe it doesn't like NT)
>
>Mike
>
>"Neal Andrews" <neal@nandrews.freeserve.co.uk> wrote:
>>Hi
>>Have a look at setting up a KeyboardProc with the AddressOf, I think it
>is a
>>system wide.
>>Look on MSDN under KeyboardProc or WH_KEYBOARD.
>>Regards
>>
>>Neal
>>
>>"sanjiv" <sanjiv@england.com> wrote in message
>>news:38d337b1$1@news.dev-archive.com...
>>>
>>> Hi,
>>> I want to trapp key_press event out side my form.I just want to
>>> know about each key_keypress while my application is running(even outside
>>> my application)
>>> I will be thanking you all.
>>>
>>> Regards
>>>
>>> Sanjiv
>>
>>
>
Cian at 2007-11-11 20:28:01 >

