Get Window Handle (HWND) in chrome extension - windows

I am developing a chrome extension which uses chrome's native messaging api to communicate to a host application. The host application is written in C++. Now my host application requires the Window Handle HWND of the chrome tab in which my extension is currently active.
Is there a way to do this? I can't use any of the NPAPI solutions.
I have gone through the documentation of the chrome extensions there doesn't seem to be a way to do this.
I have seen this answer: Get Window Handle of Chrome Tab from Within Extension?
But the above answer doesn't explain things clearly. Is it asking for matching the title of windows by iterating through all the windows? How do I do this? What if multiple tabs have the same title? Can Tab Id or window Id be used in some way?

Related

Open a popup (e.g. native browser) from a Teams desktop client app tab

Is there any way to pop open a browser window from a Teams app tab (desktop client)?
I came across the following link and from my interpretation of the reply it seems it's not possible.
Quoted from link for reference:
Unfortunately it’s not possible to use window.open in Teams tabs. Because we block opening of new windows to arbitrary sites within our Teams Desktop Client (for security reasons) you need to always use microsoftTeams.authentication.authenticate (if you want a popup window) or microsoftTeams.tasks.startTask (if you want an iframe-based dialog) to open a secondary app view.
It's not very clear to me what the microsoftTeams.authentication.authenticate reference above is suggesting.
Alternatively, if not a browser window, can we attempt to open another app installed on the device (e.g. Excel)?
Thanks in advance!
Are you just wanting to launch a new browser entirely? If so, a regular anchor tag, with a target attribute (e.g. ...), will work fine (I'm doing this in a tab myself, and it's working without problem).
You could try using a TaskModule to open a custom HTML/ Javascript or an iframe based widget inside a popup from within your Teams tab.
microsoftTeams.authentication.authenticate() will let you Authenticate the user against you tab. You can find the docs for this here.

Can we register global hotkeys for a browser

We want to register browser events even when the browser is minimized or not in focus. For example, suppose we are doing something in Microsoft Word and if we press a key on the keyboard (which is not associated with any shortcut of Word or the Windows OS), it should open a new tab in Google Chrome.
The solution will be browser specific. You'll need to create an XPCOM plug-in for Firefox, native app for Chrome, extension for IE, etc. This browser specific add-on will have to register each hotkey with the Windows API and then handle hotkey events as you desire; this of course means you will need to use a language that can access the Windows API. Depending on what you want to automate in the browser you might need to create an additional plugin in pure javascript to gain full access to the browser API.

NPAPI Safari persistent identifier for browser and tabs

I have a Safari Extension and an NPAPI plug-in and am trying to get an identifier for both a browser and tab that is persistent across loads until the window/tab is closed. One of the objects that I use needs to look up a tab by some identifier. On our Windows implementation, they use windowing APIs to get the pointer to the window (to represent the tab) and walk up the parents list to get the top level window (to represent the browser).
Is there anything like this on Mac Safari?
There is no way to get a pointer to the browser's window in any Mac browser that runs plugins out of process (which includes 64-bit Safar), because windows aren't shareable across processes. Moreover, the concept seems deeply flawed on any platform; many browsers allow dragging a tab out of one window and into another. Do you want your plugin to suddenly believe it's in a new page in this case even though the user hasn't even reloaded the page?
I can't think of any way you can track tabs given that the API has no concept of tabs. I'd strongly recommend revisiting this requirement, given that it seems very arbitrary from a user perspective. (For example, if I reload a page, that's the same, but if I close a tab and then immediately re-open it using the browser's version of undo-close-tab, it's not? And as noted above, if I drag a tab between windows, the tab is somehow different?)

Windows 7 taskbar thumbnails for one app (such as in IE8)

Under Windows 7, IE 8 shows every open tab as a taskbar thumbnail. How can I achieve this in my own app?
MSN Messenger exhibits the same behavior.
I believe that this is done with the Windows API Code Pack: http://code.msdn.microsoft.com/WindowsAPICodePack
And here's a blog post explaining how "custom window previews can be used to expose a list of child windows (browser tabs) as thumbnail- and peek-enabled windows in the taskbar." Sounds like what you need: http://blogs.microsoft.co.il/blogs/sasha/archive/2009/02/12/windows-7-taskbar-apis.aspx
The following article should help. There are several new taskbar features in Windows 7, all of them are discussed at the link below.
http://msdn.microsoft.com/en-us/magazine/dd942846.aspx
Note that the Aero Peek feature has nothing to do with task bar buttons, it just lets you make all windows fully transparent to preview your desktop and gadgets. What you were actually looking for is "Windows 7 Grouped Taskbar Thumbnails", in case you need to do additional searches.
This is the best reference I've got. Note that I'm assuming native code here, a .NET equivalent could be p/invoke'd up in a fairly straight forward manner.
It boils down to the following:
For each tab, create a proxy window
For these windows call DwmSetWindowAttribute to set DWMWA_FORCE_ICONIC_REPRESENTATION & DWMWA_HAS_ICONIC_THUMBNAIL
Whenever these proxy windows receives a WM_DWMSENDICONICLIVEPREVIEWBITMAP message, render the corresponding thumbnail into the proxy window
Whenever a proxy window receives a WM_ACTIVATE, switch to the correct tab
You also need to handle WM_SYSCOMMAND
Grab your ITaskbarList4
Use it to register each of your proxy windows as a tab
Manage tab order and what not via the ITaskbarList4 interface (this includes activating tabs)
It seems like there should be a better way to do this, but its all I'm aware of at the moment.

Open a URL in Firefox in current tab/window from a Windows application?

I have a Windows application that works with Firefox. If Firefox is already open, I'd like to have it open a given URL in the current tab+window as is currently showing. Our application tends to open a lot of URLs and reusing the same browser window makes the most sense. I already have a COM application that works with Internet Explorer, but haven't been able to find something similar for an external application to work with Firefox.
The only way I know of to do this in Firefox is to set the browser.link.open_newwindow preference to 1. Unfortunately this also stops all in-page links from opening a new tab or window.
If you use SeaMonkey as your default browser then you can use the Preferences window under Tabbed Browsing or Link Behaviour to make links from external applications open in the current tab.

Resources