node-process-windows icon indicating copy to clipboard operation
node-process-windows copied to clipboard

getActiveWindow Dont work

Open d4rckh opened this issue 5 years ago • 1 comments

var processWindows = require("node-process-windows");
 
processWindows.getActiveWindow((err, processInfo) => {

    if (err) console.log(err)

    console.log("Active window title: " + processInfo.mainWindowTitle);
});

Dont log anything

d4rckh avatar Aug 03 '18 15:08 d4rckh

Reading into the code, I found out this method does nothing, even though it's demoed in the Readme.

function getActiveWindow(callback) {
    callback = callback || noop;

    if (!isWindows) {
        callback("Non-windows platforms are currently not supported");
    }
}

It never executes the subprocess or calls callback(). All of the code to do this is pretty much there, and I think the creator might have just forgotten to commit the final version or something. Anyway, the last update was 2 years ago, so I'm making a fork to fix this.

If you want to fix the module yourself in the mean time, change the function to

function getActiveWindow(callback) {
    executeProcess("--activewindow", callback)
}

And copy windows-console-app.exe from node-process-windows/windows-console-app/windows-console-app/bin/Debug to /bin/Release. This is what makes me think this is a mistake, the fully built binary is in Debug, it just hasn't been copied to Release to implement the --activewindow feature.

adamsoutar avatar Nov 28 '18 20:11 adamsoutar