robotgo/examples/scale/main.go

52 lines
1.3 KiB
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)
2023-02-01 18:25:11 +00:00
defer robotgo.FreeBitmap(bitmap)
// bitmap.Save(bitmap, "test.png")
2022-01-02 22:32:07 +00:00
robotgo.Save(robotgo.ToImage(bitmap), "test.png")
2018-07-20 15:59:43 +00:00
2023-02-01 18:25:11 +00:00
robotgo.Scale = true
robotgo.Move(10, 10)
robotgo.MoveSmooth(100, 100)
fmt.Println(robotgo.Location())
num := robotgo.DisplaysNum()
for i := 0; i < num; i++ {
rect := robotgo.GetScreenRect(i)
fmt.Println("rect: ", rect)
}
}
func old() {
2023-01-23 02:38:28 +00:00
sx := robotgo.ScaleX() // Deprecated
s := robotgo.Scale1() // Deprecated, use the ScaleF() function
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
mx, my := robotgo.Location()
2018-11-02 17:17:42 +00:00
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)
2023-02-01 18:25:11 +00:00
defer robotgo.FreeBitmap(bit1)
// bitmap.Save(bit1, "test2.png")
2022-01-02 22:32:07 +00:00
robotgo.Save(robotgo.ToImage(bit1), "test2.png")
2018-07-20 15:59:43 +00:00
clo := robotgo.GetPixelColor(robotx, roboty)
fmt.Println("GetPixelColor...", clo)
}