Add multi screen examples code and fixed args

This commit is contained in:
vcaesar 2022-01-26 09:26:16 -08:00
parent 168a26ff5d
commit 18243a2192
2 changed files with 28 additions and 5 deletions

View File

@ -12,6 +12,7 @@ package main
import (
"fmt"
"strconv"
"github.com/go-vgo/robotgo"
// "go-vgo/robotgo"
@ -26,8 +27,24 @@ func bitmap() {
gbitMap := robotgo.CaptureGo()
fmt.Println("Go CaptureScreen...", gbitMap.Width)
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
// robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
img := robotgo.CaptureImg()
robotgo.Save(img, "save.png")
num := robotgo.DisplaysNum()
for i := 0; i < num; i++ {
robotgo.DisplayID = i
img1 := robotgo.CaptureImg()
path1 := "save_" + strconv.Itoa(i)
robotgo.Save(img1, path1+".png")
robotgo.SaveJpeg(img1, path1+".jpeg", 50)
img2 := robotgo.CaptureImg(10, 10, 20, 20)
path2 := "test_" + strconv.Itoa(i)
robotgo.Save(img2, path2+".png")
robotgo.SaveJpeg(img2, path2+".jpeg", 50)
}
}
func color() {
@ -64,6 +81,12 @@ func screen() {
// gets the screen width and height
sx, sy := robotgo.GetScreenSize()
fmt.Println("get screen size: ", sx, sy)
for i := 0; i < robotgo.DisplaysNum(); i++ {
s1 := robotgo.ScaleF(i)
fmt.Println("ScaleF: ", s1)
}
sx, sy = robotgo.GetScaleSize()
fmt.Println("get screen sclae size: ", sx, sy)
color()
}

View File

@ -222,9 +222,9 @@ func GetPixelColor(x, y int, displayId ...int) string {
}
// GetMouseColor get the mouse pos's color
func GetMouseColor() string {
func GetMouseColor(displayId ...int) string {
x, y := GetMousePos()
return GetPixelColor(x, y)
return GetPixelColor(x, y, displayId...)
}
func displayIdx(id ...int) int {
@ -319,8 +319,8 @@ func CaptureScreen(args ...int) CBitmap {
} else {
// Get the main screen rect.
rect := GetScreenRect(displayId)
x = C.int32_t(rect.X)
y = C.int32_t(rect.Y)
// x = C.int32_t(rect.X)
// y = C.int32_t(rect.Y)
w = C.int32_t(rect.W)
h = C.int32_t(rect.H)
}