mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-08 17:43:55 +00:00
add more examples
This commit is contained in:
parent
4ff2a48182
commit
a2ac46c3be
@ -30,6 +30,9 @@ func main() {
|
|||||||
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
||||||
fmt.Println("CaptureScreen...", bitmap)
|
fmt.Println("CaptureScreen...", bitmap)
|
||||||
|
|
||||||
|
gbit := robotgo.ToBitmap(bitmap)
|
||||||
|
fmt.Println("go bitmap", gbit, gbit.Width)
|
||||||
|
|
||||||
// searches for needle in bitmap
|
// searches for needle in bitmap
|
||||||
fx, fy := robotgo.FindBit(bitmap)
|
fx, fy := robotgo.FindBit(bitmap)
|
||||||
fmt.Println("FindBitmap------", fx, fy)
|
fmt.Println("FindBitmap------", fx, fy)
|
||||||
|
@ -25,6 +25,13 @@ func main() {
|
|||||||
// importing "Hello World"
|
// importing "Hello World"
|
||||||
robotgo.TypeString("Hello World")
|
robotgo.TypeString("Hello World")
|
||||||
|
|
||||||
|
robotgo.TypeString("留给真爱你的人")
|
||||||
|
robotgo.TypeStr("留给真爱你的人")
|
||||||
|
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0))
|
||||||
|
robotgo.UnicodeType(ustr)
|
||||||
|
|
||||||
|
robotgo.PasteStr("粘贴字符串, paste")
|
||||||
|
|
||||||
// press "enter"
|
// press "enter"
|
||||||
robotgo.KeyTap("enter")
|
robotgo.KeyTap("enter")
|
||||||
robotgo.KeyTap("a", "control")
|
robotgo.KeyTap("a", "control")
|
||||||
|
@ -25,6 +25,13 @@ func key() {
|
|||||||
// importing "Hello World"
|
// importing "Hello World"
|
||||||
robotgo.TypeString("Hello World")
|
robotgo.TypeString("Hello World")
|
||||||
|
|
||||||
|
robotgo.TypeString("留给真爱你的人")
|
||||||
|
robotgo.TypeStr("留给真爱你的人")
|
||||||
|
ustr := uint32(robotgo.CharCodeAt("留给真爱你的人", 0))
|
||||||
|
robotgo.UnicodeType(ustr)
|
||||||
|
|
||||||
|
robotgo.PasteStr("粘贴字符串, paste")
|
||||||
|
|
||||||
// press "enter"
|
// press "enter"
|
||||||
robotgo.KeyTap("enter")
|
robotgo.KeyTap("enter")
|
||||||
robotgo.KeyTap("a", "control")
|
robotgo.KeyTap("a", "control")
|
||||||
@ -159,6 +166,9 @@ func bitmap() {
|
|||||||
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
bitmap := robotgo.CaptureScreen(100, 200, 30, 40)
|
||||||
fmt.Println("CaptureScreen...", bitmap)
|
fmt.Println("CaptureScreen...", bitmap)
|
||||||
|
|
||||||
|
gbit := robotgo.ToBitmap(bitmap)
|
||||||
|
fmt.Println("go bitmap", gbit, gbit.Width)
|
||||||
|
|
||||||
// searches for needle in bitmap
|
// searches for needle in bitmap
|
||||||
fx, fy := robotgo.FindBit(bitmap)
|
fx, fy := robotgo.FindBit(bitmap)
|
||||||
fmt.Println("FindBitmap------", fx, fy)
|
fmt.Println("FindBitmap------", fx, fy)
|
||||||
@ -286,8 +296,13 @@ func window() {
|
|||||||
fpid, err := robotgo.FindIds("Google")
|
fpid, err := robotgo.FindIds("Google")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Println("pids...", fpid)
|
fmt.Println("pids...", fpid)
|
||||||
|
if len(fpid) > 0 {
|
||||||
|
robotgo.ActivePID(fpid[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
robotgo.ActiveName("chrome")
|
||||||
|
|
||||||
// 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 {
|
||||||
|
@ -55,8 +55,13 @@ func main() {
|
|||||||
fpid, err := robotgo.FindIds("Google")
|
fpid, err := robotgo.FindIds("Google")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
fmt.Println("pids...", fpid)
|
fmt.Println("pids...", fpid)
|
||||||
|
if len(fpid) > 0 {
|
||||||
|
robotgo.ActivePID(fpid[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
robotgo.ActiveName("chrome")
|
||||||
|
|
||||||
// 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 {
|
||||||
|
@ -63,7 +63,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version string = "v0.47.0.485, Mount Cook!"
|
version string = "v0.47.0.487, Mount Cook!"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
Loading…
Reference in New Issue
Block a user