mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 00:33:55 +00:00
Update Kill, README.md and examples
This commit is contained in:
parent
007a4d2ba6
commit
3c4a887903
@ -237,14 +237,18 @@ func main() {
|
|||||||
|
|
||||||
if len(fpid) > 0 {
|
if len(fpid) > 0 {
|
||||||
robotgo.ActivePID(fpid[0])
|
robotgo.ActivePID(fpid[0])
|
||||||
|
|
||||||
|
robotgo.Kill(fpid[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
robotgo.ActiveName("chrome")
|
robotgo.ActiveName("chrome")
|
||||||
|
|
||||||
isExist, err := robotgo.PidExists(100)
|
isExist, err := robotgo.PidExists(100)
|
||||||
if err == nil {
|
if err == nil && isExist {
|
||||||
fmt.Println("pid exists is", isExist)
|
fmt.Println("pid exists is", isExist)
|
||||||
|
|
||||||
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
abool := robotgo.ShowAlert("test", "robotgo")
|
abool := robotgo.ShowAlert("test", "robotgo")
|
||||||
|
@ -235,14 +235,18 @@ func main() {
|
|||||||
|
|
||||||
if len(fpid) > 0 {
|
if len(fpid) > 0 {
|
||||||
robotgo.ActivePID(fpid[0])
|
robotgo.ActivePID(fpid[0])
|
||||||
|
|
||||||
|
robotgo.Kill(fpid[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
robotgo.ActiveName("chrome")
|
robotgo.ActiveName("chrome")
|
||||||
|
|
||||||
isExist, err := robotgo.PidExists(100)
|
isExist, err := robotgo.PidExists(100)
|
||||||
if err == nil {
|
if err == nil && isExist {
|
||||||
fmt.Println("pid exists is", isExist)
|
fmt.Println("pid exists is", isExist)
|
||||||
|
|
||||||
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
abool := robotgo.ShowAlert("test", "robotgo")
|
abool := robotgo.ShowAlert("test", "robotgo")
|
||||||
|
@ -308,6 +308,8 @@ func window() {
|
|||||||
fmt.Println("pids...", fpid)
|
fmt.Println("pids...", fpid)
|
||||||
if len(fpid) > 0 {
|
if len(fpid) > 0 {
|
||||||
robotgo.ActivePID(fpid[0])
|
robotgo.ActivePID(fpid[0])
|
||||||
|
|
||||||
|
robotgo.Kill(fpid[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,8 +317,10 @@ func window() {
|
|||||||
|
|
||||||
// determine whether the process exists
|
// determine whether the process exists
|
||||||
isExist, err := robotgo.PidExists(100)
|
isExist, err := robotgo.PidExists(100)
|
||||||
if err == nil {
|
if err == nil && isExist {
|
||||||
fmt.Println("pid exists is", isExist)
|
fmt.Println("pid exists is", isExist)
|
||||||
|
|
||||||
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the all process id
|
// get the all process id
|
||||||
|
@ -57,6 +57,8 @@ func main() {
|
|||||||
fmt.Println("pids...", fpid)
|
fmt.Println("pids...", fpid)
|
||||||
if len(fpid) > 0 {
|
if len(fpid) > 0 {
|
||||||
robotgo.ActivePID(fpid[0])
|
robotgo.ActivePID(fpid[0])
|
||||||
|
|
||||||
|
robotgo.Kill(fpid[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +66,10 @@ func main() {
|
|||||||
|
|
||||||
// determine whether the process exists
|
// determine whether the process exists
|
||||||
isExist, err := robotgo.PidExists(100)
|
isExist, err := robotgo.PidExists(100)
|
||||||
if err == nil {
|
if err == nil && isExist {
|
||||||
fmt.Println("pid exists is", isExist)
|
fmt.Println("pid exists is", isExist)
|
||||||
|
|
||||||
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the all process id
|
// get the all process id
|
||||||
|
@ -63,7 +63,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.48.0.506, Ben Nevis!"
|
version string = "v0.48.0.508, Ben Nevis!"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -1414,7 +1414,7 @@ func ActiveName(name string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Kill kill the process by PID
|
// Kill kill the process by PID
|
||||||
func Kill(pid int) error {
|
func Kill(pid int32) error {
|
||||||
ps := os.Process{Pid: pid}
|
ps := os.Process{Pid: int(pid)}
|
||||||
return ps.Kill()
|
return ps.Kill()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user