keybd_event problems.

T

TC

Hi All. I've asked this question before and didn't get any solid answers,
but the application went cold, so I left it alone.

The app has re-surfaced so I'm back on it but face the same frustrating
problems, I hope someone has come accross this and has an answer.

It's a compact framework application written in VB.

I'm using the keybd_event api to throw characters at the system curser.
From all the examples I can find you basically set the api call up with the
ascii value of the key to send (or byte) and depress and release the key

keybd_event(byt(t), 0, 0, 0)
keybd_event(byt(t), 0, KEYEVENTF_KEYUP, 0)

However, if I want to send the character 'a', and I have done this with
bytes and hardcoded ascii values, I send the number 97, which represents a
in the ascii page. The result is '1'

I can send any Upper Case alpha character without problems. What is
stranger, if I send other data, ie. '*' or '^' I hit control keys, close
windows and all sorts of odd things happen on the portable.

Has anyone got any idea what is wrong here? I'm sure it's something really
simple I've over looked, but it's driving me nutts!

Cheers.
 
T

TC

Ok, I think I'm getting somewhere with this.

There isn't a difference between a and A on the keyboard, the shift key
makes this difference. So that's cool.

So, all numbers and alphas are fine, but what about the , . / \ [ ] ; '
characters? These don't map to the ascii table at all, so I'm still stucj
with those. I understand that the difference between / and ? will be the
shift key, but what is the code for / or any of the other lower case non
language characters?

Anyone have any resource?

I've found a couple of web pages with some information on, but most of it is
comflicting and doesn't work.

Any help would be very much appreciated.
Cheers.
 
P

Paul G. Tobey [eMVP]

For printable characters, you're much better-off using PostKeybdMessage()
than keybd_event(). In my wedging code, that sends data from serial ports,
TCP network ports, etc., to the keyboard stream, the only things I use
keybd_event() for are items like Ctrl, Alt, Enter (which you could do with
PostKeybdMessage(), too, but it's more-consistent this way), etc. I'm
surprised that I didn't suggest this previously, if you asked...

Paul T.

TC said:
Ok, I think I'm getting somewhere with this.

There isn't a difference between a and A on the keyboard, the shift key
makes this difference. So that's cool.

So, all numbers and alphas are fine, but what about the , . / \ [ ] ; '
characters? These don't map to the ascii table at all, so I'm still stucj
with those. I understand that the difference between / and ? will be the
shift key, but what is the code for / or any of the other lower case non
language characters?

Anyone have any resource?

I've found a couple of web pages with some information on, but most of it
is comflicting and doesn't work.

Any help would be very much appreciated.
Cheers.


TC said:
Hi All. I've asked this question before and didn't get any solid
answers, but the application went cold, so I left it alone.

The app has re-surfaced so I'm back on it but face the same frustrating
problems, I hope someone has come accross this and has an answer.

It's a compact framework application written in VB.

I'm using the keybd_event api to throw characters at the system curser.
From all the examples I can find you basically set the api call up with
the ascii value of the key to send (or byte) and depress and release the
key

keybd_event(byt(t), 0, 0, 0)
keybd_event(byt(t), 0, KEYEVENTF_KEYUP, 0)

However, if I want to send the character 'a', and I have done this with
bytes and hardcoded ascii values, I send the number 97, which represents
a in the ascii page. The result is '1'

I can send any Upper Case alpha character without problems. What is
stranger, if I send other data, ie. '*' or '^' I hit control keys, close
windows and all sorts of odd things happen on the portable.

Has anyone got any idea what is wrong here? I'm sure it's something
really simple I've over looked, but it's driving me nutts!

Cheers.
 
T

TC

Many thanks for you reply. It's a wedge type app I'm working on actually,
it's a WM5 unit that people will connect to various blue tooth devices which
are in turn connected to various bits of equipment.

I'll have a look at PostKeybdMessage. Do you have any VB CF code you could
show me to get started with?

Cheers.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
For printable characters, you're much better-off using PostKeybdMessage()
than keybd_event(). In my wedging code, that sends data from serial
ports, TCP network ports, etc., to the keyboard stream, the only things I
use keybd_event() for are items like Ctrl, Alt, Enter (which you could do
with PostKeybdMessage(), too, but it's more-consistent this way), etc.
I'm surprised that I didn't suggest this previously, if you asked...

Paul T.

TC said:
Ok, I think I'm getting somewhere with this.

There isn't a difference between a and A on the keyboard, the shift key
makes this difference. So that's cool.

So, all numbers and alphas are fine, but what about the , . / \ [ ] ; '
characters? These don't map to the ascii table at all, so I'm still
stucj with those. I understand that the difference between / and ? will
be the shift key, but what is the code for / or any of the other lower
case non language characters?

Anyone have any resource?

I've found a couple of web pages with some information on, but most of it
is comflicting and doesn't work.

Any help would be very much appreciated.
Cheers.


TC said:
Hi All. I've asked this question before and didn't get any solid
answers, but the application went cold, so I left it alone.

The app has re-surfaced so I'm back on it but face the same frustrating
problems, I hope someone has come accross this and has an answer.

It's a compact framework application written in VB.

I'm using the keybd_event api to throw characters at the system curser.
From all the examples I can find you basically set the api call up with
the ascii value of the key to send (or byte) and depress and release the
key

keybd_event(byt(t), 0, 0, 0)
keybd_event(byt(t), 0, KEYEVENTF_KEYUP, 0)

However, if I want to send the character 'a', and I have done this with
bytes and hardcoded ascii values, I send the number 97, which represents
a in the ascii page. The result is '1'

I can send any Upper Case alpha character without problems. What is
stranger, if I send other data, ie. '*' or '^' I hit control keys, close
windows and all sorts of odd things happen on the portable.

Has anyone got any idea what is wrong here? I'm sure it's something
really simple I've over looked, but it's driving me nutts!

Cheers.
 
P

Paul G. Tobey [eMVP]

I doubt it. I'm really a utility provider (we are a device OEM), not an
application developer. We ship a DLL that does the wedging and a couple of
applications that use it for various things like serial port wedging.
Here's what I do have (C#):

[DllImport("coredll.dll", EntryPoint="PostKeybdMessage",
SetLastError=true)]
internal static extern bool PostKeybdMessage(IntPtr hwnd, uint vKey,
KeyStateFlags flags, uint cCharacters, KeyStateFlags[] pShiftStateBuffer,
uint[] pCharacterBuffer);

This is provided by OpenNETCF's Smart Device Framework (along with a bunch
of the VK defines, I think). That's probably the place to go.

Paul T.

TC said:
Many thanks for you reply. It's a wedge type app I'm working on actually,
it's a WM5 unit that people will connect to various blue tooth devices
which are in turn connected to various bits of equipment.

I'll have a look at PostKeybdMessage. Do you have any VB CF code you
could show me to get started with?

Cheers.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
For printable characters, you're much better-off using PostKeybdMessage()
than keybd_event(). In my wedging code, that sends data from serial
ports, TCP network ports, etc., to the keyboard stream, the only things I
use keybd_event() for are items like Ctrl, Alt, Enter (which you could do
with PostKeybdMessage(), too, but it's more-consistent this way), etc.
I'm surprised that I didn't suggest this previously, if you asked...

Paul T.

TC said:
Ok, I think I'm getting somewhere with this.

There isn't a difference between a and A on the keyboard, the shift key
makes this difference. So that's cool.

So, all numbers and alphas are fine, but what about the , . / \ [ ] ; '
characters? These don't map to the ascii table at all, so I'm still
stucj with those. I understand that the difference between / and ? will
be the shift key, but what is the code for / or any of the other lower
case non language characters?

Anyone have any resource?

I've found a couple of web pages with some information on, but most of
it is comflicting and doesn't work.

Any help would be very much appreciated.
Cheers.


Hi All. I've asked this question before and didn't get any solid
answers, but the application went cold, so I left it alone.

The app has re-surfaced so I'm back on it but face the same frustrating
problems, I hope someone has come accross this and has an answer.

It's a compact framework application written in VB.

I'm using the keybd_event api to throw characters at the system curser.
From all the examples I can find you basically set the api call up with
the ascii value of the key to send (or byte) and depress and release
the key

keybd_event(byt(t), 0, 0, 0)
keybd_event(byt(t), 0, KEYEVENTF_KEYUP, 0)

However, if I want to send the character 'a', and I have done this with
bytes and hardcoded ascii values, I send the number 97, which
represents a in the ascii page. The result is '1'

I can send any Upper Case alpha character without problems. What is
stranger, if I send other data, ie. '*' or '^' I hit control keys,
close windows and all sorts of odd things happen on the portable.

Has anyone got any idea what is wrong here? I'm sure it's something
really simple I've over looked, but it's driving me nutts!

Cheers.
 
T

TC

Many thanks.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
I doubt it. I'm really a utility provider (we are a device OEM), not an
application developer. We ship a DLL that does the wedging and a couple of
applications that use it for various things like serial port wedging.
Here's what I do have (C#):

[DllImport("coredll.dll", EntryPoint="PostKeybdMessage",
SetLastError=true)]
internal static extern bool PostKeybdMessage(IntPtr hwnd, uint vKey,
KeyStateFlags flags, uint cCharacters, KeyStateFlags[] pShiftStateBuffer,
uint[] pCharacterBuffer);

This is provided by OpenNETCF's Smart Device Framework (along with a bunch
of the VK defines, I think). That's probably the place to go.

Paul T.

TC said:
Many thanks for you reply. It's a wedge type app I'm working on
actually, it's a WM5 unit that people will connect to various blue tooth
devices which are in turn connected to various bits of equipment.

I'll have a look at PostKeybdMessage. Do you have any VB CF code you
could show me to get started with?

Cheers.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
For printable characters, you're much better-off using
PostKeybdMessage() than keybd_event(). In my wedging code, that sends
data from serial ports, TCP network ports, etc., to the keyboard stream,
the only things I use keybd_event() for are items like Ctrl, Alt, Enter
(which you could do with PostKeybdMessage(), too, but it's
more-consistent this way), etc. I'm surprised that I didn't suggest this
previously, if you asked...

Paul T.

Ok, I think I'm getting somewhere with this.

There isn't a difference between a and A on the keyboard, the shift key
makes this difference. So that's cool.

So, all numbers and alphas are fine, but what about the , . / \ [ ] ; '
characters? These don't map to the ascii table at all, so I'm still
stucj with those. I understand that the difference between / and ?
will be the shift key, but what is the code for / or any of the other
lower case non language characters?

Anyone have any resource?

I've found a couple of web pages with some information on, but most of
it is comflicting and doesn't work.

Any help would be very much appreciated.
Cheers.


Hi All. I've asked this question before and didn't get any solid
answers, but the application went cold, so I left it alone.

The app has re-surfaced so I'm back on it but face the same
frustrating problems, I hope someone has come accross this and has an
answer.

It's a compact framework application written in VB.

I'm using the keybd_event api to throw characters at the system
curser. From all the examples I can find you basically set the api
call up with the ascii value of the key to send (or byte) and depress
and release the key

keybd_event(byt(t), 0, 0, 0)
keybd_event(byt(t), 0, KEYEVENTF_KEYUP, 0)

However, if I want to send the character 'a', and I have done this
with bytes and hardcoded ascii values, I send the number 97, which
represents a in the ascii page. The result is '1'

I can send any Upper Case alpha character without problems. What is
stranger, if I send other data, ie. '*' or '^' I hit control keys,
close windows and all sorts of odd things happen on the portable.

Has anyone got any idea what is wrong here? I'm sure it's something
really simple I've over looked, but it's driving me nutts!

Cheers.
 

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