<legend id='k8N9z'><style id='k8N9z'><dir id='k8N9z'><q id='k8N9z'></q></dir></style></legend><tfoot id='k8N9z'></tfoot>
      • <bdo id='k8N9z'></bdo><ul id='k8N9z'></ul>

      1. <small id='k8N9z'></small><noframes id='k8N9z'>

      2. <i id='k8N9z'><tr id='k8N9z'><dt id='k8N9z'><q id='k8N9z'><span id='k8N9z'><b id='k8N9z'><form id='k8N9z'><ins id='k8N9z'></ins><ul id='k8N9z'></ul><sub id='k8N9z'></sub></form><legend id='k8N9z'></legend><bdo id='k8N9z'><pre id='k8N9z'><center id='k8N9z'></center></pre></bdo></b><th id='k8N9z'></th></span></q></dt></tr></i><div id='k8N9z'><tfoot id='k8N9z'></tfoot><dl id='k8N9z'><fieldset id='k8N9z'></fieldset></dl></div>
      3. 如何从 chrome 获取打开的标签列表?|C#

        时间:2023-06-04

          <tbody id='taKcy'></tbody>

            <legend id='taKcy'><style id='taKcy'><dir id='taKcy'><q id='taKcy'></q></dir></style></legend>
            <i id='taKcy'><tr id='taKcy'><dt id='taKcy'><q id='taKcy'><span id='taKcy'><b id='taKcy'><form id='taKcy'><ins id='taKcy'></ins><ul id='taKcy'></ul><sub id='taKcy'></sub></form><legend id='taKcy'></legend><bdo id='taKcy'><pre id='taKcy'><center id='taKcy'></center></pre></bdo></b><th id='taKcy'></th></span></q></dt></tr></i><div id='taKcy'><tfoot id='taKcy'></tfoot><dl id='taKcy'><fieldset id='taKcy'></fieldset></dl></div>
              <bdo id='taKcy'></bdo><ul id='taKcy'></ul>
                  <tfoot id='taKcy'></tfoot>

                  <small id='taKcy'></small><noframes id='taKcy'>

                  本文介绍了如何从 chrome 获取打开的标签列表?|C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  所以我想从 google chrome 中提取打开的标签(标题、URL)并列出主题,就像在 chrome 任务管理器中一样.到目前为止,我已尝试过滤所有 chrome 进程并获取窗口标题,但这不起作用:

                  So I want to extract the open tabs from google chrome (title, URL) and list theme out kind of like in the chrome task manager. So far I have tried to filter all the chrome processes and get the window titles but that doesn't work:

                  var procs = Process.GetProcesses();
                  
                  ...
                  
                  foreach (var proc in procs)
                  {
                     if (Convert.ToString(proc.ProcessName) == "chrome")
                     {
                        Console.WriteLine("{0}: {1} | {2} | {3} ||| {4}
                  ", i, proc.ProcessName, runtime, proc.MainWindowTitle, proc.Handle);
                     }
                  }
                  

                  这并没有给我标签的地址或标题,还有其他方法吗?

                  This doesn't give me the address or the title of the tab, is there another way to do it?

                  推荐答案

                  先引用两个dll

                  UIAutomationClient.dll
                  UIAutomationTypes.dll
                  

                  位于:C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.0(或 3.5)

                  然后

                  using System.Windows.Automation;
                  

                  和代码

                  Process[] procsChrome = Process.GetProcessesByName("chrome");
                  if (procsChrome.Length <= 0)
                  {
                     Console.WriteLine("Chrome is not running");
                  }
                  else
                  {
                     foreach (Process proc in procsChrome)
                     {
                        // the chrome process must have a window 
                        if (proc.MainWindowHandle == IntPtr.Zero)
                        {
                            continue;
                        }
                        // to find the tabs we first need to locate something reliable - the 'New Tab' button 
                        AutomationElement root = AutomationElement.FromHandle(proc.MainWindowHandle);
                        Condition condNewTab = new PropertyCondition(AutomationElement.NameProperty, "New Tab");
                        AutomationElement elmNewTab = root.FindFirst(TreeScope.Descendants, condNewTab);
                        // get the tabstrip by getting the parent of the 'new tab' button 
                        TreeWalker treewalker = TreeWalker.ControlViewWalker;
                        AutomationElement elmTabStrip = treewalker.GetParent(elmNewTab);
                        // loop through all the tabs and get the names which is the page title 
                        Condition condTabItem = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem);
                        foreach (AutomationElement tabitem in elmTabStrip.FindAll(TreeScope.Children, condTabItem))
                        {
                            Console.WriteLine(tabitem.Current.Name);
                        }
                     }
                  }
                  

                  这篇关于如何从 chrome 获取打开的标签列表?|C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Winforms 中控制用户工作流程 下一篇:复制 TabControl 选项卡

                  相关文章

                  最新文章

                  • <bdo id='vZboq'></bdo><ul id='vZboq'></ul>

                    <small id='vZboq'></small><noframes id='vZboq'>

                  1. <legend id='vZboq'><style id='vZboq'><dir id='vZboq'><q id='vZboq'></q></dir></style></legend>
                    <i id='vZboq'><tr id='vZboq'><dt id='vZboq'><q id='vZboq'><span id='vZboq'><b id='vZboq'><form id='vZboq'><ins id='vZboq'></ins><ul id='vZboq'></ul><sub id='vZboq'></sub></form><legend id='vZboq'></legend><bdo id='vZboq'><pre id='vZboq'><center id='vZboq'></center></pre></bdo></b><th id='vZboq'></th></span></q></dt></tr></i><div id='vZboq'><tfoot id='vZboq'></tfoot><dl id='vZboq'><fieldset id='vZboq'></fieldset></dl></div>

                      <tfoot id='vZboq'></tfoot>