keybd_event !

T

TC

Hi all, hope someone can help here. I have a couple of problems with the
keybd_event routine in VB.Net for a portable application, either PPC2003 or
WM5, the results are the same. The following code takes a text string (dat)
and sends the output to the cursor.

Dim byt As Byte() = StrToByteArray(dat)
For t As Integer = 0 To UBound(byt)
keybd_event(byt(t), 0, 0, 0)
Next

Public Function StrToByteArray(ByVal str As String) As Byte()
Dim s As Char()
s = str.ToCharArray
Dim b(s.Length - 1) As Byte
For i As Integer = 0 To s.Length - 1
b(i) = Convert.ToByte(s(i))
Next
s = Nothing
Return b
End Function

The problems are as follows:
1. I want the option of forcing upper case, but the keyboard setting on the
portable over-rides my string convertion, if the portable keyboard is in
lower case I only ever get lower case chars.
2. I want to be able to 'replace' characters in the original data string,
but I can only do this if I replace with Upper case characters, for example
if I replace 5 with T it works, if I replace 5 with t, the string is shown
without any char where 5 is.

I assume there are loads of different settings for keyb_event(byt, x, x, x),
can anyone point me to a list of x's, or have any ideas?

Cheers.
 
T

TC

Having thought about this for a few, I think the problem is fundamentaly
with the keybd_event, this is obviously sending data to the keyboard, so the
CAPS state and all the rest of the problems seem to be coming in.

So, I suppose what I really need is code to throw characters directly at the
cursor and remove the keyboard from the whole process.

Anyone have any sample code for this in VB.Net for the PPC2003 or MW5
platform?
 
T

TC

I've also noticed something else that I just can't understand. Using the
code in the first post, if I send 123456 I get 123456. If I send 111123456
I get 123456. Same subsequent characters are being missed. This simply
wont do!

Any help on this subject would be very much appreciated.
 
F

Family Tree Mike

TC said:
I've also noticed something else that I just can't understand. Using the
code in the first post, if I send 123456 I get 123456. If I send 111123456
I get 123456. Same subsequent characters are being missed. This simply
wont do!

Any help on this subject would be very much appreciated.

I'm not familiar with keybd_event, so I googled it and MSDN. Have you seen
the article that says it is superseded by SendInput()?

From MSDN:
keybd_event Function
The keybd_event function synthesizes a keystroke. The system can use such a
synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The
keyboard driver's interrupt handler calls the keybd_event function.

Windows NT/2000/XP/Vista:This function has been superseded. Use SendInput
instead.
 
T

TC

Yeah, I've looked all over, SendInput doesn't appear to be available on the
portable, or if it is, information for the VB programmer is pretty much non
existent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top