mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-05-31 06:13:55 +00:00
Update examples
This commit is contained in:
parent
cc2d0198ea
commit
ca337b8505
@ -1,34 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
|
||||||
)
|
|
||||||
|
|
||||||
func colorPicker() {
|
|
||||||
// click the left mouse button to get the value
|
|
||||||
m := robotgo.AddEvent("mleft")
|
|
||||||
if m {
|
|
||||||
x, y := robotgo.GetMousePos()
|
|
||||||
fmt.Println("mouse pos: ", x, y)
|
|
||||||
|
|
||||||
clo := robotgo.GetPixelColor(x, y)
|
|
||||||
fmt.Println("color: #", clo)
|
|
||||||
|
|
||||||
// clipboard
|
|
||||||
s1 := fmt.Sprint(x, ", ", y) + ": " + "#" + clo
|
|
||||||
err := robotgo.WriteAll(s1)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("clipboard err: ", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
fmt.Println("color picker: ")
|
|
||||||
fmt.Println("click the left mouse button to get the value.")
|
|
||||||
for {
|
|
||||||
colorPicker()
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,8 @@ func main() {
|
|||||||
fmt.Println("get scale screen size: ", width, height)
|
fmt.Println("get scale screen size: ", width, height)
|
||||||
|
|
||||||
bitmap := robotgo.CaptureScreen(0, 0, width, height)
|
bitmap := robotgo.CaptureScreen(0, 0, width, height)
|
||||||
robotgo.SaveBitmap(bitmap, "test.png")
|
// robotgo.SaveBitmap(bitmap, "test.png")
|
||||||
|
robotgo.Save(robotgo.ToImage(bitmap), "test.png")
|
||||||
|
|
||||||
sx := robotgo.ScaleX()
|
sx := robotgo.ScaleX()
|
||||||
s := robotgo.Scale()
|
s := robotgo.Scale()
|
||||||
@ -27,7 +28,8 @@ func main() {
|
|||||||
rx, ry, rw, rh := sx, sy, robotx, roboty
|
rx, ry, rw, rh := sx, sy, robotx, roboty
|
||||||
// bit1 := robotgo.CaptureScreen(10, 20, robotw, roboth)
|
// bit1 := robotgo.CaptureScreen(10, 20, robotw, roboth)
|
||||||
bit1 := robotgo.CaptureScreen(rx, ry, rw, rh)
|
bit1 := robotgo.CaptureScreen(rx, ry, rw, rh)
|
||||||
robotgo.SaveBitmap(bit1, "test2.png")
|
// robotgo.SaveBitmap(bit1, "test2.png")
|
||||||
|
robotgo.Save(robotgo.ToImage(bit1), "test2.png")
|
||||||
|
|
||||||
clo := robotgo.GetPixelColor(robotx, roboty)
|
clo := robotgo.GetPixelColor(robotx, roboty)
|
||||||
fmt.Println("GetPixelColor...", clo)
|
fmt.Println("GetPixelColor...", clo)
|
||||||
|
@ -27,7 +27,7 @@ func bitmap() {
|
|||||||
fmt.Println("GoCaptureScreen...", gbitMap.Width)
|
fmt.Println("GoCaptureScreen...", gbitMap.Width)
|
||||||
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
|
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
|
||||||
|
|
||||||
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
|
// robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func color() {
|
func color() {
|
||||||
|
Loading…
Reference in New Issue
Block a user