Lolo
Lolo

Reputation: 133

How to get the title of the foreground process/window

I am developping a crossplatform desktop application using Electron, nodeJs and angular2. My application needs to know, at all time, which foreground process/window is running on the computer. Do you have any idea on how to achieve such a task ?

Upvotes: 6

Views: 3570

Answers (2)

Manuel
Manuel

Reputation: 846

To get metadata on active window you can use sindresorhus/active-win: it is multi platform (win, osx, linux) and very easy to implement

Upvotes: 4

hya
hya

Reputation: 1738

First of all you need to detect platform which runs Node app:

os.platform() - https://nodejs.org/dist/latest-v5.x/docs/api/os.html#os_os_platform

Then you need to run platform specific command for getting process info with child_process.exec().

https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback

Upvotes: 3

Related Questions