从扩展内部获取Chrome标签的窗口句柄? [英] Get Window Handle of Chrome Tab from Within Extension?

查看:1554
本文介绍了从扩展内部获取Chrome标签的窗口句柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个Chrome扩展程序(也包含NPAPI),允许我的应用程序和Chrome相互通信。这是所有大多数工作正常。



我现在要做的是能够将Chrome窗口的HWND绑定到特定的Window ID&标签ID。

当我使用Chrome浏览器(通过插件)时,我拥有Tab ID和Window ID,我可以基于此进行大部分操作。

当我在Chrome之外(通过我的应用程序)时,我可以看到窗口结构并获取各个选项卡的HWND。



有没有什么方法可以将它们可靠地绑定在一起,以便我的应用程序可以告诉Chrome向我提供有关/从特定选项卡的信息?

解决方案

如果您有Spy ++,您会看到网站标题与标签页标题保持一致。您应该明确地使用它。



要消除标题冲突,只需调用 chrome.tabs.query()和<$从扩展名c $ c> chrome.tabs.update()保存,更改和恢复标签的标题。然后使用 GetCurrentProcess() EnumWindows() / WindowEnumProc()获取子窗口层次结构并匹配您的自定义标题。您将不得不将它传递给EnumWindowsProc回调函数。

I've written a Chrome Extension (w/ NPAPI as well) that allows my application and Chrome to communicate with each other. That is all mostly working fine.

What I'm trying to do now is be able to tie the HWND of a Chrome window to a particular Window ID & Tab ID.

When I'm inside of Chrome (via the plugin) I have the Tab ID and Window ID and I can do most operations based on that.

When I'm outside of Chrome (via my application) I can see the window structure and get the HWND of the various tabs.

Is there any way that I can tie them together reliably such that my application could tell Chrome to get me information about/from a specific tab?

解决方案

If you have Spy++ you'll see that site titles stay consistent with tab window titles. You should definitely use that.

To eliminate title collisions simply call chrome.tabs.query() and chrome.tabs.update() from extension to save, change, and restore a tab's title. Then use GetCurrentProcess() and EnumWindows()/WindowEnumProc() to get child windows hierarchy and match your custom title. You will have to pass it to an EnumWindowsProc callback function.

这篇关于从扩展内部获取Chrome标签的窗口句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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