robotgo/examples/scale/main.go

35 lines
827 B
Go
Raw Permalink Normal View History

2018-07-20 15:59:43 +00:00
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
2018-11-01 19:10:58 +00:00
//
// syscall.NewLazyDLL("user32.dll").NewProc("SetProcessDPIAware").Call()
2018-07-20 15:59:43 +00:00
width, height := robotgo.GetScaleSize()
2018-11-01 19:10:58 +00:00
fmt.Println("get scale screen size: ", width, height)
2018-07-20 15:59:43 +00:00
bitmap := robotgo.CaptureScreen(0, 0, width, height)
robotgo.SaveBitmap(bitmap, "test.png")
2018-11-01 19:10:58 +00:00
sx := robotgo.ScaleX()
2018-07-20 15:59:43 +00:00
s := robotgo.Scale()
2018-11-02 17:17:42 +00:00
robotx, roboty := 35*s/100, 25*s/100
2018-11-01 19:10:58 +00:00
fmt.Println("scale: ", sx, s, " pos: ", robotx, roboty)
2018-10-23 14:53:08 +00:00
2018-11-02 17:17:42 +00:00
mx, my := robotgo.GetMousePos()
sx, sy := mx*s/100, my*s/100
rx, ry, rw, rh := sx, sy, robotx, roboty
// bit1 := robotgo.CaptureScreen(10, 20, robotw, roboth)
bit1 := robotgo.CaptureScreen(rx, ry, rw, rh)
2018-07-20 15:59:43 +00:00
robotgo.SaveBitmap(bit1, "test2.png")
clo := robotgo.GetPixelColor(robotx, roboty)
fmt.Println("GetPixelColor...", clo)
}