Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

Hide chrome selenium browser by window handle

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:
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;
       }
bump still need help with this
Code
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);

Look into OpenProcess()
https://msdn.microsoft.com/en-ca/library...s.85).aspx

It returns the handle, you should be able to read/write even when you've changed the process name.

You can also look into WriteProcessMemory() for changing the process name opposed to using JavaScript, and approach it using the typical read/write process methods. 
https://msdn.microsoft.com/en-us/library...s.85).aspx


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Luffy-_-Aug 20, 2023 02:06 AM 12 445 Aug 20, 2023 02:06 AM
Last Post: Lucky4L
[Python] by Don CezarAug 20, 2023 01:37 AM 5 496 Aug 20, 2023 01:37 AM
Last Post: Lucky4L
by darkfantaOct 22, 2022 11:14 AM 6 364 Oct 22, 2022 11:14 AM
Last Post: darkfanta