Hi, im working on basic macro program. I want to select applications by window name and sending keys(f5 f1 etc.) to them basically.

The problem is, sendkeys dont work on non-active windows. I search for this problem internet.

I can get window names to combobox with;

foreach (Process FFget in Process.GetProcesses())
    if (FFget.MainWindowTitle.Length>1)

Now i can select window, which is i want to sending keys. I can get any information about windows from FFget.

Im also found a basic function, which is using keybd_event.

private void Presskey(byte keyCode)
  const int KEYEVENTF_EXTENDEDKEY = 0x1;
  const int KEYEVENTF_KEYUP = 0x2;
  keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
  keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);

With that i can send to keys to activate window.

Now question is how can i sending keys to non-active window.

Im found examples for delphi, but there is no for c#.

Edited by wlalth: n/a

8 Years
Discussion Span
Last Post by __avd

Im already done similar thing to that. But i want to sending keys to non active windows, without active them.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.