diff --git a/examples/screen/main.go b/examples/screen/main.go index 118a8b9..aaa04af 100644 --- a/examples/screen/main.go +++ b/examples/screen/main.go @@ -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() } diff --git a/robotgo.go b/robotgo.go index c60374c..9ac4b87 100644 --- a/robotgo.go +++ b/robotgo.go @@ -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) }