mirror of
https://github.com/go-vgo/robotgo
synced 2026-05-23 17:59:12 +00:00
add active window by name
This commit is contained in:
parent
77ce3b91d7
commit
0feb5ee1b1
1 changed files with 11 additions and 1 deletions
12
robotgo.go
12
robotgo.go
|
|
@ -1312,11 +1312,21 @@ func FindIds(name string) ([]int32, error) {
|
|||
return pids, err
|
||||
}
|
||||
|
||||
// ActivePID window active by PID
|
||||
// ActivePID active window by PID
|
||||
func ActivePID(pid int32) {
|
||||
C.active_PID(C.uintptr(pid))
|
||||
}
|
||||
|
||||
// ActiveName active window by name
|
||||
func ActiveName(name string) error {
|
||||
pids, err := FindIds(name)
|
||||
if err == nil && len(pids) > 0 {
|
||||
ActivePID(pids[0])
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Kill kill the process by PID
|
||||
func Kill(pid int) error {
|
||||
ps := os.Process{Pid: pid}
|
||||
|
|
|
|||
Loading…
Reference in a new issue