Link to home
Start Free TrialLog in
Avatar of Shilling
Shilling

asked on

Low Level Keyboard read

Least i think i want a low level keybd read, unless im missing something!

i have a set of routines that react to simple keystrokes (a-z/0-9) but
the routines are not linked to anything that has focus - so i cant
use a text box or form key handler. ok so i need to poll the keys pressed...
ive looked & looked and all examples seem to show how to sendkeys and do
interesting things but nothing seems to cover this basic want.

how do i continually get the key presses from the keybd so i can process and
do stuff with?

rgds
Shilling

Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Avatar of Shilling
Shilling

ASKER

Richie,
thx for quick repsonse.
id 1610 as the virgin said to the bishop - looks gr8 but i havent got a clue what to do with it.
can u tell me how to get a handle on it.
every time i type a qwerty key i would like it to echo that key...

so if i add a form with a label1
i would like that label to echo the qwerty key press.

c = TheKeyPressed
so c = ????????????????????
label1.caption = c


thx again -
id 728 crashed me out but thats another story more to do with the thin ice im developing on than anything else.
rgds
Shilling
ASKER CERTIFIED SOLUTION
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Richie,

r u asking re initial question.

i am writing a program that sits sits alongside a proprietary client. It is meant to keep track of what that client is doing. This is achieved by clicking on images on myForm or typing in two letter representations of those  images, etc eg 's' & '7'.

The proprietary client takes focus as is only right. To get the 's7' in at the moment you have to click on myForm to get it to register the 'a' and then the 's'.

So i need something to override this. ie run a program that polls keybd and passes values to my prog, whomever has focus.

or my prob with 16:10
i would thought it would be a basic ms requirement to offer a facility to poll the keybd. I am finding the code in 1610 verbose and am confused as to what to actually call to get the keybd vals. A line of code, that gave me the handle i want, would open the door for me and i could go from there.

is that pos?

thx again.

rgds
Shilling






Richie,
im running from an environment where i cant reboot the machine - it clears my space entirely - and i cant register anything with windows - (thin ice) - this is why 16:10 wont run - no prob if it works i can pull it in later on the dev cycle when cirumstance have changed.

I just dont understand why this isnt standard vb fare - but thats not ur pob.
thx very much for help.

rgds
denis
amazingly swift response time.
rgds
Shilling.
Well, it worked!

A simple way (i don't know if it meets what you need)
Set Form's keypreview property to true, add a label (label1) with caption=""

in Keypress event of form, paste this:
Private Sub Form_KeyPress(KeyAscii As Integer)
label1.caption=label1.caption &  chr$(keyascii)
End Sub

It will not work with backspace. To do so we have to do in other way.
Richie,
but the form will always have to have focus or it doesnt work and as i am using this form to add value to a proprietary client which the user is constantly clicking and entering things into this cant be the case can it?
to work the user has to
click and enter in otherForm
then ...
click myForm
before they type in the keys to be caught
which is not practible. unless u know diferent!
Richie,
but the form will always have to have focus or it doesnt work and as i am using this form to add value to a proprietary client which the user is constantly clicking and entering things into this cant be the case can it?
to work the user has to
click and enter in otherForm
then ...
click myForm
before they type in the keys to be caught
which is not practible. unless u know diferent!
Richie,
but the form will always have to have focus or it doesnt work and as i am using this form to add value to a proprietary client which the user is constantly clicking and entering things into this cant be the case can it?
to work the user has to
click and enter in otherForm
then ...
click myForm
before they type in the keys to be caught
which is not practible. unless u know diferent!
Richie,
but the form will always have to have focus or it doesnt work and as i am using this form to add value to a proprietary client which the user is constantly clicking and entering things into this cant be the case can it?
to work the user has to
click and enter in otherForm
then ...
click myForm
before they type in the keys to be caught
which is not practible. unless u know diferent!
As i said, i didn't know the complete scenario so my first post is what you need.
Richie,
thx for all the help but i have stated in the original post: "the routines are not linked to anything that has focus - so i cant use a text box or form key handler."

ive since found an answer from one of your other experts
Q_20049306.html
which talks of directx - any comments?

On that link, there are comments from Ark, which is the author of the code at first link posted by me.
i don't know about Directx.