I've been trying to figure this out using
'[DllImport("user32.dll", EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lp1, string lp2);
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);
private void button1_Click(object sender, EventArgs e)
{
IntPtr handle = FindWindow(null, "Notepad");
if (!handle.Equals(IntPtr.Zero))
{
if (SetForegroundWindow(handle))
{
SendKeys.Send("(KEY)");
}
}
}
}
} `
But I basically want to reverse that. Ex: When I presss insert
in notepad, it will show my form.