2018-02-01 16:07:44 +00:00
|
|
|
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
|
2017-05-25 14:25:28 +00:00
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
|
// https://github.com/go-vgo/robotgo/blob/master/LICENSE
|
|
|
|
|
//
|
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"github.com/go-vgo/robotgo"
|
|
|
|
|
// "go-vgo/robotgo"
|
|
|
|
|
)
|
|
|
|
|
|
2018-10-07 16:23:50 +00:00
|
|
|
func bitmap() {
|
2017-09-07 13:42:11 +00:00
|
|
|
abitMap := robotgo.CaptureScreen()
|
|
|
|
|
fmt.Println("abitMap...", abitMap)
|
2018-01-26 17:28:02 +00:00
|
|
|
gbit := robotgo.ToBitmap(abitMap)
|
|
|
|
|
fmt.Println("bitmap...", gbit.Width)
|
2017-09-07 13:42:11 +00:00
|
|
|
|
2017-11-09 14:47:53 +00:00
|
|
|
gbitMap := robotgo.GoCaptureScreen()
|
|
|
|
|
fmt.Println("GoCaptureScreen...", gbitMap.Width)
|
2017-05-25 14:25:28 +00:00
|
|
|
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
|
|
|
|
|
|
2017-12-13 14:10:56 +00:00
|
|
|
robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
|
2018-10-07 16:23:50 +00:00
|
|
|
}
|
2017-12-13 14:10:56 +00:00
|
|
|
|
2018-10-07 16:23:50 +00:00
|
|
|
func color() {
|
2017-07-02 03:52:37 +00:00
|
|
|
// gets the pixel color at 100, 200.
|
2017-05-25 14:25:28 +00:00
|
|
|
color := robotgo.GetPixelColor(100, 200)
|
|
|
|
|
fmt.Println("color----", color, "-----------------")
|
2017-12-25 09:17:50 +00:00
|
|
|
|
2017-12-24 15:01:22 +00:00
|
|
|
clo := robotgo.GetPxColor(100, 200)
|
|
|
|
|
fmt.Println("color...", clo)
|
2017-12-25 09:17:50 +00:00
|
|
|
clostr := robotgo.PadHex(clo)
|
|
|
|
|
fmt.Println("color...", clostr)
|
|
|
|
|
|
|
|
|
|
rgb := robotgo.RgbToHex(255, 100, 200)
|
|
|
|
|
rgbstr := robotgo.PadHex(robotgo.U32ToHex(rgb))
|
|
|
|
|
fmt.Println("rgb...", rgbstr)
|
|
|
|
|
|
|
|
|
|
hex := robotgo.HexToRgb(uint32(rgb))
|
|
|
|
|
fmt.Println("hex...", hex)
|
|
|
|
|
hexh := robotgo.PadHex(robotgo.U8ToHex(hex))
|
|
|
|
|
fmt.Println("HexToRgb...", hexh)
|
2017-05-25 14:25:28 +00:00
|
|
|
|
2017-07-02 03:52:37 +00:00
|
|
|
// gets the pixel color at 10, 20.
|
2017-05-25 14:25:28 +00:00
|
|
|
color2 := robotgo.GetPixelColor(10, 20)
|
|
|
|
|
fmt.Println("color---", color2)
|
|
|
|
|
}
|
2018-07-13 11:23:09 +00:00
|
|
|
|
2018-10-07 16:23:50 +00:00
|
|
|
func screen() {
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Read the screen
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bitmap()
|
|
|
|
|
|
|
|
|
|
// gets the screen width and height
|
|
|
|
|
sx, sy := robotgo.GetScreenSize()
|
|
|
|
|
fmt.Println("...", sx, sy)
|
|
|
|
|
|
|
|
|
|
color()
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-13 11:23:09 +00:00
|
|
|
func main() {
|
|
|
|
|
screen()
|
|
|
|
|
}
|