robotgo/test/main.go

74 lines
1.7 KiB
Go
Raw Permalink Normal View History

2018-02-01 16:07:44 +00:00
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
2016-11-10 06:34:13 +00:00
// file at the top-level directory of this distribution and at
2016-12-10 15:31:47 +00:00
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
2016-11-10 06:34:13 +00:00
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
2016-10-06 10:41:37 +00:00
package main
import (
2016-12-10 15:31:47 +00:00
"fmt"
2017-12-24 13:02:14 +00:00
"reflect"
2016-10-06 10:41:37 +00:00
"github.com/go-vgo/robotgo"
)
2016-10-27 08:02:03 +00:00
func aRobotgo() {
2016-11-07 14:36:28 +00:00
abool := robotgo.ShowAlert("test", "robotgo")
if abool == 0 {
2016-12-10 15:31:47 +00:00
fmt.Println("ok@@@", "ok")
2016-11-07 14:36:28 +00:00
}
2016-10-06 10:41:37 +00:00
x, y := robotgo.GetMousePos()
2016-12-10 15:31:47 +00:00
fmt.Println("pos:", x, y)
2016-10-06 10:41:37 +00:00
2016-10-19 16:48:50 +00:00
robotgo.MoveMouse(x, y)
2016-10-19 16:21:18 +00:00
robotgo.MoveMouse(100, 200)
2016-10-24 05:50:42 +00:00
robotgo.MouseToggle("up")
for i := 0; i < 1080; i += 1000 {
2016-12-10 15:31:47 +00:00
fmt.Println(i)
2016-10-24 05:50:42 +00:00
robotgo.MoveMouse(800, i)
}
2016-12-10 15:31:47 +00:00
fmt.Println(robotgo.GetPixelColor(x, y))
2016-10-06 10:41:37 +00:00
color := robotgo.GetPixelColor(100, 200)
2016-12-10 15:31:47 +00:00
fmt.Println("color@@@", color)
2016-10-06 10:41:37 +00:00
robotgo.TypeString("Hello World")
2016-10-13 08:45:32 +00:00
// robotgo.KeyTap("a", "control")
2016-10-08 07:23:52 +00:00
robotgo.KeyTap("f1", "control")
// robotgo.KeyTap("enter")
2016-10-06 10:41:37 +00:00
// robotgo.KeyToggle("enter", "down")
robotgo.TypeString("en")
2016-12-10 15:14:56 +00:00
abitmap := robotgo.CaptureScreen()
2016-12-10 15:31:47 +00:00
fmt.Println("all...", abitmap)
2016-10-24 06:06:20 +00:00
2016-12-10 15:14:56 +00:00
bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
2016-12-10 15:31:47 +00:00
fmt.Println("...", bitmap)
2016-10-16 10:32:57 +00:00
2016-12-10 15:14:56 +00:00
fx, fy := robotgo.FindBitmap(bitmap)
2016-12-10 15:31:47 +00:00
fmt.Println("FindBitmap------", fx, fy)
2016-10-20 11:22:11 +00:00
2016-12-10 15:14:56 +00:00
robotgo.SaveBitmap(bitmap, "test.png", 1)
2016-10-20 09:32:45 +00:00
2017-12-24 13:02:14 +00:00
var bitmapTest robotgo.Bitmap
bitTest := robotgo.OpenBitmap("test.png")
bitmapTest = robotgo.ToBitmap(bitTest)
fmt.Println("...type", reflect.TypeOf(bitTest), reflect.TypeOf(bitmapTest))
2016-10-06 10:41:37 +00:00
// robotgo.MouseClick()
robotgo.ScrollMouse(10, "up")
}
func main() {
2016-10-27 08:02:03 +00:00
aRobotgo()
2016-10-06 10:41:37 +00:00
}