Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
2.43/5 (4 votes)
Google Chrome places each tab into a separate process. Only the currently selected tab has it's Process.MainWindowTitle set to the current tab's title. The other tab's do not contain this information.

Is there a way to find out the Title of each tabs from the processes?
Posted
Comments
TcJoshJohnson 2-Jun-14 13:46pm    
If I'm not mistaken, I think all tabs reside in the main UI process. Chrome spins up a new process to render the content of each tab and updates the UI through IPC. This was my understanding of the architecture anyway.
Member 11888574 5-Aug-15 15:12pm    
How we can get this process
Code projects an earn from it

sir, please see the below link. It might help you

http://stackoverflow.com/questions/18897070/getting-the-current-tabs-url-from-google-chrome-using-c-sharp[^]





thanks in advance
 
Share this answer
 
C#
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;

namespace Demo
{
    [SuppressUnmanagedCodeSecurity]
    internal static class UnsafeNativeMethods
    {
        //get title of the window

        #region Delegates

        public delegate bool EnumWindowProc(IntPtr hWnd, IntPtr parameter);

        #endregion

        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        internal static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder lpString, int nMaxCount);

        //find the window handler.
        [DllImport("user32.dll", SetLastError = true)]
        internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        //hide the window.
        [DllImport("user32.dll")]
        internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        //To get child window
        [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
        public static extern IntPtr GetWindow(IntPtr hwnd, int wFlag);

        //To get child window
        [DllImport("user32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr i);
    }
}
 
Share this answer
 
Comments
Amey K Bhatkar 21-Jul-14 3:37am    
let me know if you want description.
You can enumerate all windows of the process and determine the main window (the main window usually has WS_CAPTION, WS_SYSMENU and other special styles). Then call GetWindowText() for that window to get its title.
 
Share this answer
 
try this, hope it works..


C#
Process[] processes = Process.GetProcessesByName("chrome");
string name = processes[i].MainWindowTitle;
 
Share this answer
 
Comments
Valery Possoz 21-Jun-14 6:01am    
That does not work... only the active tab has it's MainWindowTitle set. All the other processes have an empty window title.
I am not 100% sure if this is what you are looking for but I used it a couple of times.
http://stackoverflow.com/questions/16958051/get-chrome-browser-title-using-c-sharp
 
Share this answer
 
C#
Process[] p = Process.GetProcessesByName("chrome");
foreach (Process item in p)
{
   MessageBox.Show(item.MainWindowTitle);
}


Try like this ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900