Donovan wrote:

> G'Day,
>
> > Paul Ritchie said:
> > SetWindowsHookEx.
> > Hours of fun - guaranteed.
>
> And how right he was..... ;-( After playing with this for a while I still
> have one __MAJOR__ frustration. Namely that I cannot seem to be
> able to set
> the hook to be for the cmd.exe thread that I kick off with a
> CreateProcess(). I have a DLL with the hook procedure in it, and a
> standalone EXE that simply invokes a CMD.EXE via a
> CreateProcess() and then
> sets a keyboard hook to capture all the keystrokes in the console window.

[snip]

>
> And this works for my application thread. So __why__ does it not
> work for a
> cmd.exe created with CreateProcess()? What am I missing here? Something
> __really__ subtle I am sure....
>

Hrmm.. I suspect it could be that SetWindowsHookEx is part of the Win32
subsystem (of course :-) which CMD.EXE (being a console application) isn't -
i.e. it doesn't have a message and system event queue to 'hook'.

The Win32 created _console_ window application which is relaying keystrokes
to it _does_ have a message and system event queue as it's part of the Win32
subsystem so you might be able to attach a WindowsHook to _that_ if you can
find it's thread id and/or window handle.

I'd go hunting through the Win32 Console API docs myself.

Now, this is all guess work based on my memory of reading 'Inside Windows
NT' many years aho. YMMV.

TTFN,
  Paul.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to