I created a Process. That one has a MainWindow I want to SendKeys.Send("+F") (CTRL+F) to, but I don't know how to do this.
So how is this done?
I created a Process. That one has a MainWindow I want to SendKeys.Send("+F") (CTRL+F) to, but I don't know how to do this.
So how is this done?
For Ctrl key you need to precede the key code with ^. something like:
SendKeys.Send("^F");
Check here for more information.
You'll need something like the following to set focus to an external window:
public class Form1 : Form
{
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
Process[] process = Process.GetProcessesByName("notepad");
if (process.Length > 0)
SetForegroundWindow(process[0].MainWindowHandle);
}
}