Re: keybd_event problems.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Many thanks.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:OmJz5wNwIHA.5472@xxxxxxxxxxxxxxxxxxxxxxx
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" <tull@xxxxxxxxxxxxxxxx> wrote in message
news:uPH8SmNwIHA.552@xxxxxxxxxxxxxxxxxxxxxxx
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:OPcKrWNwIHA.3968@xxxxxxxxxxxxxxxxxxxxxxx
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" <tull@xxxxxxxxxxxxxxxx> wrote in message
news:e0ZJDwMwIHA.576@xxxxxxxxxxxxxxxxxxxxxxx
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" <tull@xxxxxxxxxxxxxxxx> wrote in message
news:uBomk6LwIHA.4772@xxxxxxxxxxxxxxxxxxxxxxx
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.











.



Relevant Pages

  • Re: keybd_event problems.
    ... applications that use it for various things like serial port wedging. ... KeyStateFlags flags, uint cCharacters, KeyStateFlagspShiftStateBuffer, ... These don't map to the ascii table at all, ... case non language characters? ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Serial Communications in ASCII
    ... > I would like to write something that can send and receive ASCII ... > characters over a serial port, then pass them somewhere else for ... > All the resources I have been able to find are vague or don't have ... > Am I likely to need any extra libraries for C, or is serial port ...
    (comp.lang.c)
  • Re: Serial port monitoring
    ... if (!characters) return; ... you would not want to use blocking I/O on a serial port. ... I would then have a loop that checks for char in serial buffer. ...
    (microsoft.public.vc.mfc)
  • Re: display output from serial port device
    ... If your program fails to open the serial port, ... If you do want parity, restore INPCK, but also add PARENB to ... always get the right number of characters. ...
    (comp.os.linux.development.system)
  • RE: SerialPort read&write members display string value above 127 as "?
    ... Serial Port Class methods of Read and Write default to ASCII code ... namespace EncodeTest1 ... // A Unicode string with two characters outside an 8-bit code ... "This unicode string contains two characters " + ...
    (microsoft.public.dotnet.framework)