writing a keyboard wedge

  • Thread starter Thread starter Sagaert Johan
  • Start date Start date
S

Sagaert Johan

Hi

Can someone point me the good direction to start a project that injects
keycodes, or (scancodes ) into the system as if the came from the keyboard.
(like barcodescanners etc.. do)

Johan
 
Hello Sagaert,

Use SendMessage WinAPI function
http://www.pinvoke.net/default.aspx/coredll/SendMessage.html

SJ> Hi
SJ>
SJ> Can someone point me the good direction to start a project that
SJ> injects keycodes, or (scancodes ) into the system as if the came
SJ> from the keyboard. (like barcodescanners etc.. do)
SJ>
SJ> Johan
SJ>
---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
Michael Nemtsev said:
S Johan wrote:
SJ> Can someone point me the good direction to start a project that
SJ> injects keycodes, or (scancodes ) into the system as if the came
SJ> from the keyboard. (like barcodescanners etc.. do)
Use SendMessage WinAPI function
http://www.pinvoke.net/default.aspx/coredll/SendMessage.html

I think that normally SendMessage isn't the best way. It's too
targetted and specific, e.g. knowing precisely which window to send
the message to.

SendInput is better. This is a low-level call to "spoof" mouse-clicks
and keyboard presses. I don't know if there's a managed wrapper; I'd
use p-invoke.

Here's an example win32/c++ program I wrote which intercepts the right
alt key, and spoofs a right-mouse-click in response. It shows how I
used SendInput.
http://www.wischik.com/lu/Programmer/Keymouse
 
Michael,

This is actually not what you want to do, as it doesn't simulate input
from devices (keyboard, mice, etc, etc).

The OP really wants the SendInput API function that will produce
keyboard input.

Hope this helps.
 
Hi

Can someone point me the good direction to start a project that injects
keycodes, or (scancodes ) into the system as if the came from the keyboard.
(like barcodescanners etc.. do)

Johan
As well as the other suggestions, SendKeys.Send() might be useful for
you. The online help does include a caution however: "If your
application is intended for international use with a variety of
keyboards, the use of Send() could yield unpredictable results and
should be avoided."


rossum
 
Thanks ,

I will have a look at it, seems in the direction of my needs.

Nicholas Paldino said:
Michael,

This is actually not what you want to do, as it doesn't simulate input
from devices (keyboard, mice, etc, etc).

The OP really wants the SendInput API function that will produce
keyboard input.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Michael Nemtsev said:
Hello Sagaert,

Use SendMessage WinAPI function
http://www.pinvoke.net/default.aspx/coredll/SendMessage.html

SJ> Hi
SJ> SJ> Can someone point me the good direction to start a project that
SJ> injects keycodes, or (scancodes ) into the system as if the came
SJ> from the keyboard. (like barcodescanners etc.. do)
SJ> SJ> Johan
SJ> ---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
 

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

Back
Top