Enumerate browser tabs from external application - browser

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:
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:
Enable sounds (which I don't prefer)
Watch the window/tab/page title for the alternating flashing "Gmail" / "Blah says..." message.
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.
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)
...
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.
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.

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).
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.

Related

Sound does not play in background tab

I've a small Extension which keeps checking for some data on a website.
On specific event it plays a sound file using:
document.getElementById("audio-beep1").play();
However practically this page isn't the foreground page since I'll be working on some other tab so this sound does not play even though event is detected.
So as I click this tab - sound plays.
Is there any way the sound will play on event even if the tab isn't the foreground one?
Google added an update in the past ~6 months or so, a The Great Suspender knockoff called "Tab Freezing" and "Tab Discarding."
That's why you can't play audio in a background tab. Google has suspended the tab without telling you. It's also why the second you click the tab, it starts playing the audio -- the tab is unfrozen, and re-loaded. This is proving to be a nightmare for one of my clients, as they use Incontact MAX, and if Chrome gets a chance, it simply wrecks the VOIP system.
I do not have a solution for you. Google, in their great and unending wisdom, decided this feature does not need any ability to be configured, disabled, or anything of the sort. Nor did they ask you if you wanted this function to be enabled. Truth be told, they appear to be very embarrassed about the unholy amounts of RAM that Chrome uses, and this is their kludge filled workaround.
(You were once able to disable this feature in chrome://flags but they have removed it from said window, and did not add it to the settings menu.)
And no, telling Chrome not to auto discard in chrome://discards does not actually stop it from doing this.
One suggestion I've heard is looping an audio file that is either not making any noise or so quiet it cannot be heard -- like a 1 second loop of dead air. This might trick Chrome into not freezing or discarding the tab, as it's actively playing audio. No idea if this will work. Another I'm planning to test out is using The Great Suspender on the background tab, and seeing if that prevents Google's thing from working.
Playing sound may do the trick, as tab playing sound is an active tab - but it's an ugly hack and consumes resources unnecessary.
Apparently as of now (12.07.2021) you can Disable tab freezing by this setting: chrome://flags/#calculate-native-win-occlusion
Set it to Disabled and tabs freezing should not happen any more. Here is a source

Force Google Doc to open without Print Layout view

Writing guides in Google Docs and sharing them with other people as read-only is great. However, even when formatting it without the "Print Layout" option (the first toggle option under View menu), every viewer opening the document will see it in Print Layout, i.e. with half-empty pages before each page break. This is very annoying.
Is there any way to default the Print Layout to be switched OFF when a read-only viewer opens a Google Doc? Here are 2 ways for which I'm hoping:
via a URL parameter, so that the link I share determines the document will open with a switched-off Print Layout;
in Google Apps Script, with something like function onOpen(){ DocumentApp.getActiveDocument().setPrintLayout(false); }
(except setPrintLayout() does not seem to exist right now).
I'm mostly interested in the web browser version, and in the mobile app too (though less).
There's a similar question over there (with screenshots).
And there's a discussion dating back when switching off Print Layout in read-only Google Docs was not yet possible (it is, now, though only manually).

Can a Chrome extension change its large (new tab page) icon?

My question is along the same lines as this: Change the Chrome extension icon
But I'm wondering instead about the large icon of the extension on a new tab page. Can it change itself based on data? All I have in mind is a simple countdown-calendar (as in, the whole point of the extension is to be a big ol' number on your new tab page), so the actual code wouldn't have to be very long, if icon-changing is possible. (It wouldn't even need to sync or connect to the Internet for any reason.)
My strong hunch is no, because I've never seen an extension do so, and I would expect that if it could, my Chrome's Gmail button would probably display the number of new messages or something. But I figured it didn't hurt to ask.
PS: I've never created a Chrome extension, I just had that idea for one just now. Anyone reading this can feel free to do it themselves, but otherwise I'll make it when I get the time, as a learning exercise.
Only apps (not extensions) can have an icon on the New Tab page (NTP).
This icon have to be declared via the icons property in the manifest file, and cannot dynamically be updated.
I can imagine two ways to get a dynamic icon on the options page:
Create an extension that replaces the New Tab page. Have a look at the docs for Override Pages.
Create an extension that uses the chrome.management API to enable/disable apps. This method might work for your personal setup, but it requires a new App for each icon. This feels a bit hacky, but hey, it might work.

Feasibility of grouping tabs in Chrome

I'd like to be able to group tabs in Chrome (on Windows Vista/7 primarily), as I can with Tab Mix Plus on Firefox, so that I only see one group in the tab list at one time. I don't seem to be the only one, but it hasn't been done, so far as I can tell. There are plenty of tab managers out there, like TooManyTabs and Tab Outliner, which summarise, save and unload tabs, but they don't leave them loaded whilst hiding them.
I've not coded a Chrome extension before, but I think the specific problem is that you can't control the visibility of tabs (in the way you can with the hidden attribute of tabs in Firefox) or windows from a Chrome extension. Is that right, or have I missed something in the API?
If that is right, any way anyone can see to hack round this? Put the tabs I want invisible in a window and then use whatever Windows API allows http://www.hide-window.com/ to hide that window?

Stuck on frozen frame using online CRM Dynamics

Every now and then (and sufficiently often to be bothered by), I get stuck in a modal window when e.g. creating a new filter, task, appointment etc. The window is movable but I can't close it by pressing the red X in the corner, save-and-close-it nor F4 it. The window lives and the buttons react visually but the frame doesn't close.
My best solution this far is to kill the process and log in again. That makes me sad...
I suspect that the behavior might have to do with my system configuration: I'm on Win8 with IE10 (set to compatibility mode) powered by CRM Dynamics 2011 in the cloud.
Can someone confirm the behavior?
Any hits on how to deal with it (other than installing IE9)?
(Before I'd set the compatibility mode on, I experienced some funny effects such as the "Get started"-section rolling and getting wider and wider like some cool jQuery-effect. Now it's under control, though.)
Maybe not a solution, but have you changed your IE settings to force new popups to open as a new tab, instead of a new window? I've never experienced the issue you describe, but it may allow you to close it, since it is a tab, and not a window...

Resources