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 puter. Do you have any idea on how to achieve such a task ?
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 puter. Do you have any idea on how to achieve such a task ?
Share Improve this question asked Mar 20, 2017 at 20:22 Lolo Lolo 1332 silver badges7 bronze badges 1- Maybe the solution is different for each OS. In this case, I prefer to have a solution working on Linux puters first. – Lolo Commented Mar 20, 2017 at 20:26
2 Answers
Reset to default 4To get metadata on active window you can use sindresorhus/active-win: it is multi platform (win, osx, linux) and very easy to implement
First of all you need to detect platform which runs Node app:
os.platform()
- https://nodejs/dist/latest-v5.x/docs/api/os.html#os_os_platform
Then you need to run platform specific mand for getting process info with child_process.exec()
.
https://nodejs/api/child_process.html#child_process_child_process_exec_mand_options_callback