mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-07 09:03:57 +00:00
Merge pull request #170 from redstarcoder/master
Update FindIds doc and only set name once in loop
This commit is contained in:
commit
e6a2085c2a
@ -1565,7 +1565,8 @@ func FindNames() ([]string, error) {
|
|||||||
return strArr, err
|
return strArr, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FindIds find the all process id by the process name
|
// FindIds finds the all processes named with a subset of "name" (case insensitive),
|
||||||
|
// return matched IDs.
|
||||||
func FindIds(name string) ([]int32, error) {
|
func FindIds(name string) ([]int32, error) {
|
||||||
var pids []int32
|
var pids []int32
|
||||||
nps, err := Process()
|
nps, err := Process()
|
||||||
@ -1573,9 +1574,9 @@ func FindIds(name string) ([]int32, error) {
|
|||||||
return pids, err
|
return pids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = strings.ToLower(name)
|
||||||
for i := 0; i < len(nps); i++ {
|
for i := 0; i < len(nps); i++ {
|
||||||
psname := strings.ToLower(nps[i].Name)
|
psname := strings.ToLower(nps[i].Name)
|
||||||
name = strings.ToLower(name)
|
|
||||||
abool := strings.Contains(psname, name)
|
abool := strings.Contains(psname, name)
|
||||||
if abool {
|
if abool {
|
||||||
pids = append(pids, nps[i].Pid)
|
pids = append(pids, nps[i].Pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user