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) { comboBox1.Items.Add(FFget.MainWindowTitle.ToString()); } }
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#.
You should have to look at this article - http://www.codeproject.com/KB/cs/SendKeys.aspx
Im already done similar thing to that. But i want to sending keys to non active windows, without active them.
Read - How can I send keys to a non active window?