Get Window Handle of Chrome Tab from Within Extension?

自古美人都是妖i 提交于 2019-12-10 16:09:11

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11472708/get-window-handle-of-chrome-tab-from-within-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!