waitingsong / node-win32-api

win32 api
MIT License
430 stars 55 forks source link

How to make an application invisible in the background? #46

Closed CarmenLexa closed 2 months ago

CarmenLexa commented 1 year ago

I am using the following code to call a windows application

var { spawn } = require('child_process');
const local_path = "C:\\Users\\PC\\\Documents\\";
const query = exec("start /B game.exe", { cwd: `${local_path}`,windowsHide: true });
const pid = query.pid;

how can i use win32-api?

waitingsong commented 1 year ago

try: https://github.com/waitingsong/node-windows-window-controller/blob/master/src/lib/index.ts#L11

kihlh commented 1 year ago

try:https://www.npmjs.com/package/hmc-win32 The module is a deeply wrapped win32-api

const hmc = require('hmc-win32');
 hmc.openApp("game.exe","",`${local_path}`,true,false);

Hide the current console:


// Please save it to a variable if you need to continue to control it, because after hiding the handle will be blocked so that it cannot be retrieved.
let Handle = hmc.getProcessHandle(process.pid);
Handle?.hide();
// show 
Handle?.show();```