Skip to content

window processIds consistent with Node child_process subprocess pids #61

@NNskelly

Description

@NNskelly

Is your feature request related to a problem? Please describe.
My primary use case for a library like node-window-manager is when I'm making a node app to manage the execution of other apps. When I use e.g. child_process.spawn() to launch an app, I get back a process handle with a process ID. Other libraries like npm node-process-windows have a pid scheme that matches the child_process pids, so I can usually find the window of the process I just launched and attempt to manipulate it (although node-process-windows appears unable to reliably e.g. bring a window to foreground). node-window-manager finds a lot of windows, but neither the window.id nor the window.processId match the child_process pids, so I can at best compare the window paths to whatever path I launched my subprocess at, but that gets sloppy and unreliable, especially when the target path had any degree of indirection (e.g. a relative path, .lnk shortcut, etc.).

Describe the solution you'd like
Ideally, window.processId is the actual process ID, consistent between all contexts that utilize processes and process IDs. Alternatively, if window.processId is already its own thing with its own expectations elsewhere, window should have some other property or getter returning a value consistent with subprocess.pid.

Describe alternatives you've considered
As mentioned, at least one competing library already does this- node-process-windows- it simply uses a helper tool that is not capable of certain manipulations on more current Windows builds. And while it's technically possible to compare process launch paths with window paths, discrepancies can arise which make path comparison only really useful for human-review sanity-checking or isolating which window ought-probably to have the pid I'm looking for.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions