Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Get Key Function?

Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Jugoslav Dujic <jdu...@yahoo.com>
Newsgroups: comp.lang.fortran
Subject: Re: Get Key Function?
Date: Wed, 06 May 2009 09:32:00 +0200
Lines: 67
Message-ID: <76cssvF1c4gt4U1@mid.individual.net>
References: <edf0a73b-ff05-4849-90f6-2aa93445d388@v35g2000pro.googlegroups.com> 	<87zldw6ajc.fsf@roark.xbeta.org> <kYFQftBUlW$JJw7q@page.demon.co.uk> 	<gtk61k$6au$1@news.motzarella.org> <xDTl5kAOit$JJwo7@page.demon.co.uk> 	<gtmq0u$e7k$1@aioe.org> <gtnavm$72g$1@news.motzarella.org> 	<gtndg9$2tc$1@aioe.org> <c6c68a54-e46a-459e-94dd-c075e603fcbc@z19g2000vbz.googlegroups.com> 	<76a9jtF1c5d62U1@mid.individual.net> <7d1254de-7ccf-4baa-80b2-c8629461dcb6@e20g2000vbc.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net tikxEQpzYm4Kx4oqXS7pnQZps9Kg0eAZelj1i5GeAzY2xR2An7
Cancel-Lock: sha1:NHIms83ndHZvw0/Jv4Mdddf0IR8=
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
In-Reply-To: <7d1254de-7ccf-4baa-80b2-c8629461dcb6@e20g2000vbc.googlegroups.com>

GaryScott wrote:
> 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
>> inaccessibility.
> 
> 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:

program Getch
use ifwin
implicit none

integer(HANDLE):: h
type(T_MSG)::     msg
integer::         iret

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)).

--
Jugoslav
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.