How can I identify the foreground 'app' on Chrome OS?

google-chrome google-chrome-extension google-chrome-app google-chrome-os

232 просмотра

2 ответа

6 Репутация автора

I am trying to create a Chrome extension (or app) for Chrome OS that monitors the foreground app that the user is currently interacting with.

For example if the user:

  1. plays Angry Birds for a few minutes; then
  2. browses some web pages using Chrome and finally
  3. does some calculations using the Calculator

then I want my extension (or app) to be able to detect and respond to these three transitions as they occur. Ideally the information about the app that I'd like to capture is either the app name (e.g. "Angry Birds") and/or the app id (e.g. com.somecompany.someapp).

I already experimented with several of the chrome.* API's but so far I haven't had any luck:

  • and chrome.tabs can only enumerate browser windows/tabs (not those of apps).
  • can only enumerate windows that are part of it's own app (not other apps).
  • Apps are only sent their own lifecycle events and not those of other apps.
  • I might be able to use OCR on the screen cast provided by chrome.desktopCapture but I would probably have to write specific code for each app that I want to support and it would be very CPU intensive.

I have had luck doing similar work on other platforms (Windows, Mac, Linux and even Android) using accessibility client API's (same API's used by screen readers for disabled people). Unfortunately Chrome OS doesn't appear to facilitate 3rd party accessibility clients.

Автор: qypsac Источник Размещён: 18.07.2016 03:01

Ответы (2)

0 плюса

57987 Репутация автора

Chrome Extension and App APIs are listed here: Extensions, Apps.

(Un)fortunately, there isn't anything there that would allow spying on the user activity outside your context. Apps are generally limited to what happens in them (plus some hardware notifications), and extensions are generally limited to what happens in the browser.

You can detect focus loss in the browser/app, but you can't tell where the focus went.
For example, extension event will report -1 for all windows that are not part of the browser, even if it's a Chrome App.

Автор: Xan Размещён: 18.07.2016 10:02

1 плюс

199 Репутация автора

There's a feature request to add more window types to the results of -- See

Автор: moobag Размещён: 28.09.2016 02:47
Вопросы из категории :