Call ShowWindow from node via ffi-napi
Win32 only!
Hide, show, maximize or minimize a window where you know either the window's hWnd or the process' PID.
The helper methods (methods not starting with "winApi") will only work when you are running node.exe as the main process, unlike running cmd.exe -> node, which makes cmd.exe the main process. This is because they use process.pid
as the PID.
npm install --save windows-api-show-window
// run with win + r
node {repository-location}/test/index.js
var api = require("windows-api-show-window");
api.hideCurrentProcessWindow().then(() => {
// console window is hidden
}).catch(err => {
console.error(err);
});
api.showCurrentProcessWindow().then(() => {
// console window is visible
}).catch(err => {
console.error(err);
});
api.maximizeCurrentProcessWindow().then(() => {
// console window is maximized
}).catch(err => {
console.error(err);
});
api.minimizeCurrentProcessWindow().then(() => {
// console window is minimized
}).catch(err => {
console.error(err);
});
api.restoreCurrentProcessWindow().then(() => {
// console window is restored
}).catch(err => {
console.error(err);
});
api.winApiGetHwndFromPid(process.pid).then(hWnd => {
// do something with hWnd
}).catch(err => {
console.error(err);
});
api.winApiShowWindow(hWnd, api.SW_HIDE).then(() => {
// custom calls to ShowWindow
}).catch(err => {
console.error(err);
});
If node-gyp fails: Check out the node-gyp documentation and felixrieseberg/windows-build-tools