Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bryphe/node-process-windows
Manage application windows via a Node API - set focus, cycle active windows, and get active windows
https://github.com/bryphe/node-process-windows
Last synced: 16 days ago
JSON representation
Manage application windows via a Node API - set focus, cycle active windows, and get active windows
- Host: GitHub
- URL: https://github.com/bryphe/node-process-windows
- Owner: bryphe
- License: mit
- Created: 2016-08-27T21:45:49.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-30T19:41:52.000Z (12 months ago)
- Last Synced: 2024-10-13T11:14:24.982Z (about 1 month ago)
- Language: C#
- Size: 566 KB
- Stars: 34
- Watchers: 4
- Forks: 12
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-node-process-windows
###### Manage application windows via a Node API - set focus, cycle active windows, and get active windows- [Installation](#Installation)
- [Supported Platforms](#Supported_Platforms)
- [Usage](#Usage)
- [Contributing](#Contributing)
- [License](#License)
- [Contact](#Contact)## Installation
Requires Node 4+
```
npm install node-process-windows
```This module is __not supported__ in browsers.
### Supported Platforms
Currently, this module is only supported on Windows, and uses a .NET console app to manage windows.
Pull requests are welcome - it would be great to have this API work cross-platform.
## Usage
1) Get active processes
```javascript
var processWindows = require("node-process-windows");var activeProcesses = processWindows.getProcesses(function(err, processes) {
processes.forEach(function (p) {
console.log("PID: " + p.pid.toString());
console.log("MainWindowTitle: " + p.mainWindowTitle);
console.log("ProcessName: " + p.processName);
});
});
```2) Focus a window
```javascript
var processWindows = require("node-process-windows");// Focus window by process...
var activeProcesses = processWindows.getProcesses(function(err, processes) {
var chromeProcesses = processes.filter(p => p.processName.indexOf("chrome") >= 0);// If there is a chrome process active, focus the first window
if(chromeProcesses.length > 0) {
processWindows.focusWindow(chromeProcesses[0]);
}
});// Or focus by name
processWindows.focusWindow("chrome");
```3) Get active window
```javascript
var processWindows = require("node-process-windows");var currentActiveWindow = processWindows.getActiveWindow((err, processInfo) => {
console.log("Active window title: " + processInfo.mainWindowTitle);
});
```## Contributing
Pull requests are welcome
## License
[MIT License]("LICENSE")
## Contact