Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetWindowsHookEx() with WH_KEYBOARD and MS-DOS applications

82 views
Skip to first unread message

Matt Jacobs

unread,
Oct 2, 1996, 3:00:00 AM10/2/96
to

I'm using SetWindowsHookEx to set a WH_KEYBOARD hook under Windows 3.1
and Windows 95 and it works fine as long as the keyboard focus is not
on top of an MS-DOS application or the DOS prompt. I'm wondering if
there's a way to get my hook to fire in all cases, regardless of where
the keyboard focus is. Thanks.

Matt Jacobs

Tako Schotanus

unread,
Oct 2, 1996, 3:00:00 AM10/2/96
to

I can't really answer your question other than that I think that
it's not possible to get keys sent to DOS apps.

What I's like to know is why my program that uses a SetWindowsHookEx
for WH_GETMESSAGE works when I compile it using MS' 16bit compiler,
but not when I (after porting it to work with VC++ 4.2) compile it
for 32bit. I haven't changed the SetWinHookEx line and I checked
the docs to make sure that the function still works the same (which
it does more or less).

Does anybody have a working example of a VC++ 4.x project that
implements a system-wide hook? I would appreciate a copy or at
least a piece of it. ;-)

Thanks
- Tako


--
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
/_/ Tako Schotanus /_/
/_/ mailto: quin...@xs4all.nl /_/
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

Gerry Hickman

unread,
Oct 2, 1996, 3:00:00 AM10/2/96
to quin...@xs4all.nl

Hi there,

This post caught my eye as I'm trying to find out if it's possible
(under Windows 3.1 or 95) to work with "simutanious" keystrokes. In
other words pressing more than one AnphaNumeric key at a time!

I did it in Dos based C but it's timing sensitive and relies on reading
straight from the ports. I now need a windows version.

Any ideas or pointers on this would be a great help.

Thanks
Gerry

David Myers

unread,
Oct 3, 1996, 3:00:00 AM10/3/96
to

mat...@ix.netcom.com (Matt Jacobs) wrote:
>I'm using SetWindowsHookEx to set a WH_KEYBOARD hook under Windows 3.1
>and Windows 95 and it works fine as long as the keyboard focus is not
>on top of an MS-DOS application or the DOS prompt. I'm wondering if
>there's a way to get my hook to fire in all cases, regardless of where
>the keyboard focus is. Thanks.
>
>Matt Jacobs
>
>
The only way I know to intercept all keystrokes at all times (in any VM) is to write a simple VxD
which uses the Keyboard Service, VKD_Filter_Keyboard_Input, to look at every keyboard scancode
before it is processed by the System. Your VxD can then notify your application that a specific key
has been pressed and even prevent it from being sent to the System, if required.

This only works under Windows 95, under Windows 3.1, I had to modify the Keyboard driver, VKD.386
to achieve the same result.

Dave Myers.

Darryn Davis

unread,
Oct 3, 1996, 3:00:00 AM10/3/96
to

On Wed, 02 Oct 1996 15:54:48 +0100, Tako Schotanus
<quin...@xs4all.nl> wrote:

>What I's like to know is why my program that uses a SetWindowsHookEx
>for WH_GETMESSAGE works when I compile it using MS' 16bit compiler,
>but not when I (after porting it to work with VC++ 4.2) compile it
>for 32bit. I haven't changed the SetWinHookEx line and I checked
>the docs to make sure that the function still works the same (which
>it does more or less).
>
>Does anybody have a working example of a VC++ 4.x project that
>implements a system-wide hook? I would appreciate a copy or at
>least a piece of it. ;-)

Make suer that your proc is in a sperate DLL as in 16 bit it was all
easy as everything was shared but in 32 bit the Proc has to be mapped
into the address space of all processes and therefore must live in a
DLL and you must be very carefull with you data and use GLOBAL
EXPORTED data if you want all instances of your proc to share data.

>
>Thanks
> - Tako
>
>
>--
>/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
>/_/ Tako Schotanus /_/
>/_/ mailto: quin...@xs4all.nl /_/
>/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


Darryn Davis
Darry...@cit.com.au

Robert Mashlan

unread,
Oct 4, 1996, 3:00:00 AM10/4/96
to

Gerry Hickman <ger...@dircon.co.uk> wrote:

>Hi there,
>
>This post caught my eye as I'm trying to find out if it's possible
>(under Windows 3.1 or 95) to work with "simutanious" keystrokes. In
>other words pressing more than one AnphaNumeric key at a time!
>
>I did it in Dos based C but it's timing sensitive and relies on reading
>straight from the ports. I now need a windows version.

You are notified whenever the keys are pressed with WM_KEYDOWN
messages, and when they go up whit WM_KEYUP messages. If you want to
get the state of a key, use GetKeyState or GetAsyncKeyState. There's
no restriction on the number of keys that can be held down at once.


---
Robert Mashlan R2M Software rmas...@r2m.com
Internet Resources for Windows Developers http://www.r2m.com/windev/


0 new messages