C#如何杀死一个独特的标签铬浏览器。 [英] C# how to kill a unique tab chrome browser.

查看:54
本文介绍了C#如何杀死一个独特的标签铬浏览器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void Killenvent(object sender, System.EventArgs e)
      {
          Application.DoEvents();
          foreach (var ie in Process.GetProcessesByName("chrome"))
          {
              try
              {
                  ie.Kill();
              }
              catch { }
          }
      }





< b>我尝试过的事情:



大家好。我需要帮助。我想关闭一个特定的chrome选项卡。例如,具有特定链接类型youtube的选项卡,并仅在该页面上执行kill。让其他实例正常打开。因为当我确实杀了它时会关闭所有实例。

推荐答案

我认为没有办法从浏览器本身外面关闭它即使有,除非它是Chrome API for .NET的一部分,否则下次更新Chrome时可能会失败(我们都知道这些*的频率是多少!)



我认为最好的办法是考虑编写Chrome扩展程序:使用入门:构建Chrome扩展程序 - Google Chrome [ ^ ] - 但即使你去了你可能最好使用像AdBlock / uBlock这样的东西,它可以做类似的事情并将YouTube添加到黑名单中(或者只是编辑Windows Hosts文件并阻止任何访问YouTube:如何阻止Windows 10 PC上的网站 [ ^ ])
I don't think there is a way to close it from outside the browser itself and even if there was, unless it was part of a Chrome API for .NET it would be likely to fail on the next update to Chrome (and we all know how frequent *those* are!)

I think your best bet is to look into writing a Chrome Extension: Getting Started: Building a Chrome Extension - Google Chrome[^] - but even if you go that way, you're probably be better off using something like AdBlock / uBlock which can do something similar already and add YouTube to the blacklist (or just edit the Windows Hosts file and prevent any access to YouTube at all: How To Block Websites On Your Windows 10 PC[^])


这篇关于C#如何杀死一个独特的标签铬浏览器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆