Detect foreground window in ChromeOS

31 views
Skip to first unread message

Jian Huang

unread,
Sep 27, 2016, 12:21:31 AM9/27/16
to Chromium-dev
Hi,

Is it possible to know the information of foreground window in ChromeOS? Just like in linux/mac, we can do this by using xdotool.

Thanks.

Scott Violet

unread,
Sep 27, 2016, 9:20:38 AM9/27/16
to kingk...@gmail.com, Chromium-dev
Can you elaborate on where you want to do this from? Modifying chrome
code? Extension?

-Scott
> --
> --
> Chromium Developers mailing list: chromi...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-dev

Jian Huang

unread,
Sep 27, 2016, 7:42:31 PM9/27/16
to Scott Violet, Chromium-dev
Well, modifying chrome will be the last thing I want to do. 

Primarily I just want to know the title of the foreground window or the process name which the foreground window associated with in system-wide via extension/app/native client, which means my  extension/app/NaCl will run in background, it can detect any foreground window which maybe associate with other extension/app/NaCl. Just like I can do this in windows program when can call the GetForegroundWindow API.

Thank you.


Best Regards,
Huang Jian

Trent Apted

unread,
Sep 27, 2016, 8:19:50 PM9/27/16
to kingk...@gmail.com, Scott Violet, Chromium-dev
The chrome.windows.getAll extension API function [1] provides an array of `Window` which includes a `focused` property[2]. You can get the tabs browser windows, where you'll find url/title.

Some windows will be left out, but it doesn't amount to much that is interesting on ChromeOS (menus, notifications, ..).

You can typically get more help for chrome extensions on StackOverflow, but the documentation and sample code is pretty good too.

Jian Huang

unread,
Sep 27, 2016, 8:30:04 PM9/27/16
to Trent Apted, Scott Violet, Chromium-dev
Thank you Trent for your quick reply.


As the thread described, 
  • chrome.windows and chrome.tabs can only enumerate browser windows/tabs (not other apps).
That's why I highlight system-wide,

Thank you

Best Regards,
Huang Jian
Reply all
Reply to author
Forward
0 new messages