npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

winctl-kh

v1.0.4

Published

> Windows window manipulation for node.js

Downloads

1

Readme

Windows window manipulation for node.js

This package fixes the: 'Error when building: No overloaded function takes 2 arguments'

I might implement other stuff in this fork if needed.

Build status

winctl wraps a few functions of the windows api to allow iterating over currently opened windows and performing a few limited operations on them. This is not a production ready module! There is no real documentation either yet. Sorry for that.

The example has to suffice for now.

Contents

Requirements

This module is currently only compatible with Windows. Please ensure you have the required dependencies as well as Visual Studio installed.

Building

node-gyp is required to build xinput.js.

Install node-gyp using npm:

npm install -g node-gyp

Then configure and build:

node-gyp configure
node-gyp build

Example

var winctl = require('../');

var win = winctl.GetActiveWindow();

// Output some information about the currently active window
console.log("Active Window Hwnd:", win.getHwnd());
console.log("Active Window Title:", win.getTitle());
console.log("Dimensions:", win.dimensions());
/* ->
Active Window Hwnd: 26282110
Active Window Title: Bash cpp-modules/winctl
Dimensions: { left: 708, top: 112, right: 2025, bottom: 1132 }
*/

// Manipulate the currently active window a bit
// Move active window to 0,0 and resize it to 800x600
win.move(0, 0, 800, 600);

// Move active window to the right by 30px and increase its width by 60px
win.moveRelative(30, 0, 60, 0);

// Minimize the active window
win.showWindow(winctl.WindowStates.MINIMIZE);

console.log();

// Find a windows "File Explorer" window by ClassName
console.log("Title of window with class 'CabinetWClass':", winctl.GetWindowByClassName("CabinetWClass").getTitle());

// Find a window by exact title
console.log("HWND of window with exact title 'File Explorer':", winctl.GetWindowByTitleExact("File Explorer").getHwnd());

// Find first window containing the string 'alc' and bring it to the foreground
winctl.FindByTitle("alc").then(window => {
	console.log("Title of window with title 'alc':", window.getTitle());
	// --> Title of window with title 'alc': Calculator

	// Activate the window
	window.setForegroundWindow();
});

// Iterate over all windows with a custom filter -> show all visible windows
winctl.FindWindows(win => win.isVisible() && win.getTitle()).then(windows => {
	console.log("Visible windows:");
	windows.sort((a,b) => a.getTitle().localeCompare(b.getTitle())).forEach(window => console.log(" - %s [pid=%d, hwnd=%d, parent=%d]", window.getTitle(), window.getPid(), window.getHwnd(), window.getParent()));
});
/* -->
Visible windows:
 - Bash cpp-modules/winctl [pid=27196, hwnd=26282110, parent=NaN]
 - Bash cpp-modules/winctl [pid=30696, hwnd=10357510, parent=NaN]
 - Calculator [pid=6948, hwnd=5311194, parent=NaN]
 - File Explorer [pid=4860, hwnd=5115324, parent=NaN]
 - src [pid=4860, hwnd=219155192, parent=NaN]
*/


// Log when a new window opens or the active window changes
winctl.Events.addListener("active-window", function(now, prev) {
	console.log("Changed active window to: %s [prev=%s]", now.getTitle(), prev.getTitle());
});

winctl.Events.addListener("open-window", function(win) {
	console.log("Opened new window: %s [%d]", win.getTitle(), win.getHwnd());
});

// Stop listening after 5s
setTimeout(() => {
	winctl.Events.removeAllListeners("active-window");
	winctl.Events.removeAllListeners("open-window");
	console.log("---done---");
}, 5000);

License

MIT