1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
// Get a handle to an application window.
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
// Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
private void btnEnterText_Click(object sender, EventArgs e)
{
var handle = FindWindow("MozillaUIWindowClass", "Environnement de recette 1.4.0.3 - Mozilla Firefox");
SetForegroundWindow(handle);
SendKeys.SendWait(txtEntry.Text);
}
private void btnTab_Click(object sender, EventArgs e)
{
var handle = FindWindow("MozillaUIWindowClass", "Environnement de recette 1.4.0.3 - Mozilla Firefox");
SetForegroundWindow(handle);
SendKeys.SendWait("{TAB}");
} |
Partager