From 0d402e04323e8f154803bc074f397c7f78b0b798 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Mon, 6 May 2019 10:41:10 -0400 Subject: [PATCH] add process FindPath() function --- robotgo.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/robotgo.go b/robotgo.go index 688d1cb..0ef82c9 100644 --- a/robotgo.go +++ b/robotgo.go @@ -1714,6 +1714,21 @@ func FindIds(name string) ([]int32, error) { return pids, err } +// FindPath find the process path by the process pid +func FindPath(pid int32) (string, error) { + nps, err := process.NewProcess(pid) + if err != nil { + return "", err + } + + f, err := nps.Exe() + if err != nil { + return "", err + } + + return f, err +} + func internalActive(pid int32, hwnd int) { C.active_PID(C.uintptr(pid), C.uintptr(hwnd)) }