How can I identify the foreground 'app' on Chrome OS?
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:
- plays Angry Birds for a few minutes; then
- browses some web pages using Chrome and finally
- 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:
chrome.tabscan only enumerate browser windows/tabs (not those of apps).
chrome.app.windowcan only enumerate windows that are part of it's own app (not other apps).
- Apps are only sent their own
chrome.app.runtimelifecycle events and not those of other apps.
- I might be able to use OCR on the screen cast provided by
chrome.desktopCapturebut 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
57987 Репутация автора
(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.
chrome.windows.onFocusChanged extension event will report
-1 for all windows that are not part of the browser, even if it's a Chrome App.