-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use the process ID #7
Comments
Impl:
Things to note:
I don't have time for this now. |
you can use something like npm all-windows to get the metadata of all open windows, filter out the specific one you want using PiD, then grab the title from there and create an overlay. |
Slightly backwards way of doing it, as you can do it like seen here which works pretty well. Note I know as I'm working with games only one instance of the game will be open at any time with only one window. https://github.com/Videndum/twitch-extension-template/blob/master/electron/src/GameHander.ts async findGame() {
const game = getProcesses().find(p => p.szExeFile.toLowerCase() == this.GameToFind?.toLowerCase())
this.details = { name: this.details.name, process: this.details.process, ...game }
if (game) return game
else return null
}
windows = {
GetGameWindow: async () => {
let stout = (await exec(`(tasklist /FI "PID eq ${this.details.th32ProcessID}" /fo list /v)`)).stdout
let execDetails: { [x: string]: string } = {}
stout.split("\r\n").forEach(line => {
let param = line.split(":")
if (!param[1]) return
execDetails[param[0].trim()] = param[1].trim()
})
console.log(execDetails)
const details: Details = {
...this.details,
ImageName: execDetails["Image Name"],
PID: Number(execDetails["PID"]),
SessionName: execDetails["Session Name"],
Session: Number(execDetails["Session#"]),
MemUsage: execDetails["Mem Usage"],
Status: execDetails["Status"],
UserName: execDetails["User Name"],
CPUTime: execDetails["CPU Time"],
WindowTitle: execDetails["Window Title"]
}
this.details = details
return this.details
}
} Still working on a solution to mac, but following the same principle of listing all processes, finding the correct one using the name (in my case using the exe) and then finding the details which would include the window titles which can then be passed to this package. Still would be nice to be able to have this built into this package so users don't have to go through the entire process like I have |
cool, i didn't know about this tasklist method. you just saved me a lot of headaches my friend :DD |
Be very careful using tasklist so verbosely, it can hammer a users memory, our app currently does this round trip but the package has some real issues with window states that arent practical to real-world use cases. |
Heya, so I would like to use this alongside https://github.com/Rob--/memoryjs to create game extensions. I have the processID from memoryjs but would like to use this within your application to select which process should be overlayed, is that possible?
The text was updated successfully, but these errors were encountered: