Forum: Ruby speeding up GetAsyncKeyState

Posted by Michael Linfield (macgoober)
on 2009-07-02 03:36
while true

  keys.each {|k, v| print k.upcase if GetAsyncKeyState.call(v) & 0x01 ==
1 && GetAsyncKeyState.call(0x10) & 0x01 == 1}
  keys.each {|k, v| print k.downcase if GetAsyncKeyState.call(v) & 0x01
== 1}

end

GetAsyncKeyState is representing Win32API.new('user32',
'GetAsyncKeyState', ['i'], 'i')

and keys represents a hash of scan code to virtual keycode conversions.

The problem occurs as seen by running this in a console... pressing "a"
too quickly results in no secondary "a".

In short... it doesn't pick up all the keyboard input unless you type at
1 letter per 3 seconds.

Any way to speed this up?

Regards,

- Mac
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.