问题
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