1

i've been challenged to write an app simulating keystrokes. After pressing shortcut app should be able to send predefined key combination to currently active app. It is functionality provided by many existing applications, but i want to write it on my own. App should be usable on windows.

Could you provide me with suggestions about:

  1. which programming language should I choose?
  2. Is there any libraries providing such functionality?

EDIT: To be precise: both applications are standalone, windows app.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Damian Drewulski
  • 134
  • 1
  • 3
  • 11

2 Answers2

1

The native winapi for doing this is SendInput.

To answer your questions:

  1. Which programming language? This is up to you. Because this is just a simple native API call, use any language that allows you to call native API.
  2. Don't bother with libraries if this is all you need, because it's very simple.

Now, to go further, I know you didn't ask this but many many people continue by asking how to send keystrokes to windows that don't have keyboard focus - like sending keystrokes to a specific app. This is much more difficult and error-prone. And since it goes outside the behavior of actual real keystrokes, it can behave unpredictably. Here is one such question.

Community
  • 1
  • 1
tenfour
  • 36,141
  • 15
  • 83
  • 142
0

You can easily do this on C#, using

SendKeys.Send("key here");

or

SendKeys.SendWait("key here");

Some keys use other keycodes, you can see them here on MSDN.

ave
  • 287
  • 13
  • 27