mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-02 23:23:55 +00:00
add active window by name
This commit is contained in:
parent
77ce3b91d7
commit
0feb5ee1b1
12
robotgo.go
12
robotgo.go
@ -1312,11 +1312,21 @@ func FindIds(name string) ([]int32, error) {
|
|||||||
return pids, err
|
return pids, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// ActivePID window active by PID
|
// ActivePID active window by PID
|
||||||
func ActivePID(pid int32) {
|
func ActivePID(pid int32) {
|
||||||
C.active_PID(C.uintptr(pid))
|
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
|
// Kill kill the process by PID
|
||||||
func Kill(pid int) error {
|
func Kill(pid int) error {
|
||||||
ps := os.Process{Pid: pid}
|
ps := os.Process{Pid: pid}
|
||||||
|
Loading…
Reference in New Issue
Block a user