I managed to get it working on Windows 2000 by using the GetAsyncKeyState
function from user32.lib. When you read the documentation (win32api.hlp)
you’ll find out that you have to reset it first. So:
get the fct from the lib
GetAsyncKeyState = Win32API.new(“user32”,“GetAsyncKeyState”,[‘i’],‘i’)
reset the state for the ‘x’ key
GetAsyncKeyState.call(0x58)
do stuff…
if GetAsyncKeyState.call(0x58) & 0x01 == 1
# we get here when the ‘x’ key was hit
end
See also GetKeyboardState and other related functions in the Win32 SDK
reference help.
–Jakub Roth
···
-----Original Message-----
From: Jason Williams [mailto:jason@jasonandali.org.uk]
Sent: Wednesday, August 13, 2003 8:08 PM
To: ruby-talk@ruby-lang.org
Subject: Re: Read character from keyboardIn article 1751979702.20030813103416@syspoint.com.br, André
Wagner wrote:What I’m trying to write is a server on which you can type commands
(like a prompt). So I would have two threads: one for the server
processing (the socket) and another one for the prompt. The
problem is
that the socket thread won’t write anything on the screen (like a
warning message) if the prompt thread is waiting for a input.