Message from discussion Get Key Function?
From: Jugoslav Dujic <jdu...@yahoo.com>
Subject: Re: Get Key Function?
Date: Wed, 06 May 2009 09:32:00 +0200
References: <email@example.com> <firstname.lastname@example.org> <kYFQftBUlW$JJw7q@page.demon.co.uk> <email@example.com> <xDTl5kAOit$JJwo7@page.demon.co.uk> <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com> <76a9jtF1c5d62U1@mid.individual.net> <firstname.lastname@example.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-Trace: individual.net tikxEQpzYm4Kx4oqXS7pnQZps9Kg0eAZelj1i5GeAzY2xR2An7
User-Agent: Thunderbird 22.214.171.124 (Windows/20090302)
> On May 5, 2:51 am, Jugoslav Dujic <jdu...@yahoo.com> wrote:
>> GaryScott wrote:
>>> On May 4, 1:49 pm, dpb <n...@non.net> wrote:
>>>> user1 wrote:
>>>>> dpb wrote:
>>>>>> Clive Page wrote:
>>>>>>> That's sounds a good explanation. But I still don't quite know why
>>>>>>> this is needed for the single keystroke routine to work.
>>>>>> Because w/o a console there's not a keyboard input only a Windows
>>>>>> messages queue created.
>>>>> In which case you would check for a WM_CHAR message in your message
>>>>> processing loop ...
>>>> But a console app doesn't have a message processing loop (in the Windows
>>>> sense, the app may be written to be input driven, but that's not the
>>>> same thing, of course)--and the keystrokes would be sent to the active
>>>> window, not a console.
>>> Actually it does have a normal message processing loop, its just
>>> hidden from you. But you can snoop on it.
>> Not that I know of <way of snooping into it>, short of writing a
>> kernel-mode application. As far as I know (and I claim to be
>> well-versed on the subject of Windows inner workings), it's buried
>> somewhere deep into the system innards, to the point of
> It is quite easy to use the following to get the window handle:
> handle = findwindowex(null,null,"ConsoleWindowClass"//char(0),null)
> From there, you can inquire and manipulate console windows if you are
> knowledgable and careful. If you open a console application, the
> handle that it returns will be that of the current application. I
> have used peekmessage to query such things as function key values in
> the distant past.
Then, please, show me how. This does not work:
h = FindWindowEx(null,null,"ConsoleWindowClass"//char(0),null)
iret = GetMessage(msg, h, 0, 0)
if (msg%message.eq.WM_KEYDOWN) &
write(*,*) "You pressed ", char(msg%wParam)
end program Getch
Window handle is returned indeed (as expected), but GetMessage does
not work for any combination of parameters (h or NULL; 0 or WM_KEYDOWN
for messsage filtering); the program only sits in there forever. That
suggests that a /subsystem:console application does not have a regular
message queue, and that you cannot peek into it like for a regular
/subsystem:windows application. I admit I haven't tried a message
hook (SetWindowsHookEx(WH_KEYBOARD or WH_KEYBOARD_LL)).
Please reply to the newsgroup.
You can find my real e-mail on my home page above.