Update Kill, README.md and examples

This commit is contained in:
vcaesar 2018-02-03 17:42:38 +08:00
parent 007a4d2ba6
commit 3c4a887903
5 changed files with 23 additions and 7 deletions

View File

@ -237,14 +237,18 @@ func main() {
if len(fpid) > 0 {
robotgo.ActivePID(fpid[0])
robotgo.Kill(fpid[0])
}
}
robotgo.ActiveName("chrome")
isExist, err := robotgo.PidExists(100)
if err == nil {
if err == nil && isExist {
fmt.Println("pid exists is", isExist)
robotgo.Kill(100)
}
abool := robotgo.ShowAlert("test", "robotgo")

View File

@ -235,14 +235,18 @@ func main() {
if len(fpid) > 0 {
robotgo.ActivePID(fpid[0])
robotgo.Kill(fpid[0])
}
}
robotgo.ActiveName("chrome")
isExist, err := robotgo.PidExists(100)
if err == nil {
if err == nil && isExist {
fmt.Println("pid exists is", isExist)
robotgo.Kill(100)
}
abool := robotgo.ShowAlert("test", "robotgo")

View File

@ -308,6 +308,8 @@ func window() {
fmt.Println("pids...", fpid)
if len(fpid) > 0 {
robotgo.ActivePID(fpid[0])
robotgo.Kill(fpid[0])
}
}
@ -315,8 +317,10 @@ func window() {
// determine whether the process exists
isExist, err := robotgo.PidExists(100)
if err == nil {
if err == nil && isExist {
fmt.Println("pid exists is", isExist)
robotgo.Kill(100)
}
// get the all process id

View File

@ -57,6 +57,8 @@ func main() {
fmt.Println("pids...", fpid)
if len(fpid) > 0 {
robotgo.ActivePID(fpid[0])
robotgo.Kill(fpid[0])
}
}
@ -64,8 +66,10 @@ func main() {
// determine whether the process exists
isExist, err := robotgo.PidExists(100)
if err == nil {
if err == nil && isExist {
fmt.Println("pid exists is", isExist)
robotgo.Kill(100)
}
// get the all process id

View File

@ -63,7 +63,7 @@ import (
)
const (
version string = "v0.48.0.506, Ben Nevis!"
version string = "v0.48.0.508, Ben Nevis!"
)
type (
@ -1414,7 +1414,7 @@ func ActiveName(name string) error {
}
// Kill kill the process by PID
func Kill(pid int) error {
ps := os.Process{Pid: pid}
func Kill(pid int32) error {
ps := os.Process{Pid: int(pid)}
return ps.Kill()
}