枚举从外部应用程序的浏览器标签 [英] Enumerate browser tabs from external application

查看:175
本文介绍了枚举从外部应用程序的浏览器标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

奇(有挑战性?)问题的一点。是否有可能以编程方式从外部应用程序访问打开的浏览器的标签?我知道这是一个模糊的问题,但听我说:

A bit of an odd (challenging?) question. Is it possible to programmatically access the tabs of an open browser from a external application? I realize that's a vague question, but hear me out:

我试图创造一个Gmail聊天通知应用程序时,存在一个悬而未决的聊天消息在闪烁Windows系统托盘中的通知图标。现在,据我所知道的,唯一内置Gmail聊天通知是:

What I'm trying to create is a "Gmail Chat Notifier" application that flashes a notification icon in the Windows system tray when an unanswered chat message exists. Right now, as far as I can tell, the only built-in Gmail chat notifications are:


  1. 启用声音(我不preFER)

  2. 观看窗口/标签/页交替闪烁的Gmail的/嗒嗒说...消息的标题。

与#2的问题是:当最小化浏览器窗口,并在Gmail的标签是不是在有效在浏览器选项卡中,窗口标题不会改变,我不不会注意到新的聊天消息。

The problem with #2 is: When the browser window is minimized, and when the Gmail tab isn't the active tab in the browser, the window title doesn't change and I don't notice new chat messages.

所以我想创建一个手表选项卡标题为我的应用程序。 (所有选项卡标题,而不仅仅是窗口标题,这是唯一的活动标签称号。)的我创建了一个验证的概念C#应用程序通过枚举活动Windows进程和留意闪烁的嗒嗒检测未聊天消息在窗口标题说...

So I'd like to create an application that watches the tab titles for me. (All of the tab titles, not just the window title, which is only the active tab title.) I created a proof-of-concept C# application to detect unanswered chat messages by enumerating the active Windows processes and watching for the flashing "Blah says..." in the window title:

Process[] procs = Process.GetProcesses();
IntPtr hWnd;
foreach (Process proc in procs)
    if ((hWnd = proc.MainWindowHandle) != IntPtr.Zero)
    	if (proc.MainWindowTitle.IndexOf(" says… ") >= 0)
    	...

但有了这个明显的问题是,当Gmail的标签是不是活动/集中标签(因为它只着眼于窗口标题)将无法正常工作。所以,我需要的东西,可以深入挖掘并期待在标签标题。

But the obvious problem with this is that it won't work when the Gmail tab isn't the active/focused tab (since it only looks at window titles). So I need something that can dig deeper and look at the tab titles.

我接受任何东西。我一直在思考的可能的工作是寻找一种方法以某种方式列举浏览器的标签页(MDI子窗口?*手指交叉*),但也许这甚至还没有接近可能的:)我也开其他解决方案太多,如果有办法用,要说到做到这一点,火狐插件或东西(但它会是不错的与Windows系统托盘整合,而不是仅仅在浏览器沙箱存在)。

I'm open to anything. What I had been thinking might work is finding a way to enumerate the browser's tabs somehow (MDI child windows? * fingers crossed *), but maybe that's not even close to possible :) I'm also open to other solutions too if there's a way to do this with, say, Firefox plugins or something (but it'd be nice to integrate with the Windows system tray, and not just exist in the browser sandbox).

谁能帮助让我开始?感谢很多提前。

Can anyone help get me started? Thanks much in advance.

推荐答案

这是不可能的总称。浏览器选项卡不一定是MDI子窗口(事实上,他们几乎都不是)。你不知道一个任意浏览器窗口的树,所以你不能解析,找出选项卡(即使你知道这对一个特定的浏览器,它肯定是一个实现细节可能小版本之间甚至改变)。其实,你不这样做,知道如果浏览器甚至使用标签单独的Win32窗口句柄,因为它可能只是有一个手柄,它的主窗口,并通过自身内部汲取一切(如Qt和WPF应用程序做到这一点,我相信尤其是歌剧这样做,而且很可能也是如此Safari浏览器)。

It's not possible in general. Browser tabs need not be MDI child windows (in fact, they almost certainly aren't). You do not know the window tree of an arbitrary browser, so you can't parse that and figure out the tabs (and even if you knew it for a specific browser, it's definitely an implementation detail that is likely to change even between minor releases). In fact, you do not know if the browser is even using separate Win32 window handles for tabs, as it may just have one handle for its main window, and draw everything inside by itself (e.g. Qt and WPF applications do that, and I believe that Opera in particular does that, and probably so does Safari).

不限解决此将必须是浏览器的特定。你也许可以写为相应的IE和Firefox的插件,以传达信息给您的应用程序(虽然Firefox的插件是沙箱,所以我不知道,如果他们甚至能够做到的IPC)。我没有看到歌剧,Safari或Chrome的任何选项。

Any solution to this will have to be browser-specific. You can probably write corresponding plugins for IE and Firefox to communicate that info to your application (though Firefox plugins are sandboxed, so I'm not sure if they are even able to do IPC). I don't see any options for Opera, Safari or Chrome.

这篇关于枚举从外部应用程序的浏览器标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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