I was able to hide the process(selenium chrome browser) by using FindWindow and the lpWindowname by changing the browser title with Javascript. But I want to be able to hide the process(selenium chrome browser) by a different handle since the window name changes everytime it navigates to a different page.
Here is my code:
Here is my code:
Code
[DllImport("user32.dll")]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_HIDE = 0;
const int SW_SHOW = 5;
private void button1_Click_1(object sender, EventArgs e)
{
if (on)
{
IntPtr hWnd = FindWindow(null, "Window Name - Google Chrome");
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, SW_HIDE); // Hide the window
}
button1.Text = "Show";
t.Start();
on = false;
}
else {
IntPtr hWnd = FindWindow(null, "Window Name - Google Chrome");
if (hWnd != IntPtr.Zero)
{
ShowWindow(hWnd, SW_SHOW); //Show Window
}
button1.Text = "Hide";
t.Stop();
on = true;
}
