mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 08:43:56 +00:00
Update screen
This commit is contained in:
parent
54b8bf4a9b
commit
65bc4cbae7
120
robotgo.go
120
robotgo.go
@ -23,6 +23,66 @@ import (
|
|||||||
// "syscall"
|
// "syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
_______. ______ .______ _______ _______ .__ __.
|
||||||
|
/ | / || _ \ | ____|| ____|| \ | |
|
||||||
|
| (----`| ,----'| |_) | | |__ | |__ | \| |
|
||||||
|
\ \ | | | / | __| | __| | . ` |
|
||||||
|
.----) | | `----.| |\ \----.| |____ | |____ | |\ |
|
||||||
|
|_______/ \______|| _| `._____||_______||_______||__| \__|
|
||||||
|
*/
|
||||||
|
|
||||||
|
type Bit_map struct {
|
||||||
|
ImageBuffer *C.uint8_t
|
||||||
|
Width C.size_t
|
||||||
|
Height C.size_t
|
||||||
|
Bytewidth C.size_t
|
||||||
|
BitsPerPixel C.uint8_t
|
||||||
|
BytesPerPixel C.uint8_t
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPixelColor(x, y C.size_t) string {
|
||||||
|
color := C.agetPixelColor(x, y)
|
||||||
|
gcolor := C.GoString(color)
|
||||||
|
defer C.free(unsafe.Pointer(color))
|
||||||
|
return gcolor
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetScreenSize() (C.size_t, C.size_t) {
|
||||||
|
size := C.agetScreenSize()
|
||||||
|
// Println("...", size, size.width)
|
||||||
|
return size.width, size.height
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetXDisplayName() string {
|
||||||
|
name := C.agetXDisplayName()
|
||||||
|
gname := C.GoString(name)
|
||||||
|
defer C.free(unsafe.Pointer(name))
|
||||||
|
return gname
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetXDisplayName(name string) string {
|
||||||
|
cname := C.CString(name)
|
||||||
|
str := C.asetXDisplayName(cname)
|
||||||
|
gstr := C.GoString(str)
|
||||||
|
return gstr
|
||||||
|
}
|
||||||
|
|
||||||
|
func CaptureScreen(x, y, w, h C.int) Bit_map {
|
||||||
|
bit := C.acaptureScreen(x, y, w, h)
|
||||||
|
// Println("...", bit)
|
||||||
|
bit_map := Bit_map{
|
||||||
|
ImageBuffer: bit.imageBuffer,
|
||||||
|
Width: bit.width,
|
||||||
|
Height: bit.height,
|
||||||
|
Bytewidth: bit.bytewidth,
|
||||||
|
BitsPerPixel: bit.bitsPerPixel,
|
||||||
|
BytesPerPixel: bit.bytesPerPixel,
|
||||||
|
}
|
||||||
|
|
||||||
|
return bit_map
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
__ __
|
__ __
|
||||||
| \/ | ___ _ _ ___ ___
|
| \/ | ___ _ _ ___ ___
|
||||||
@ -146,42 +206,32 @@ func SetKeyboardDelay(x C.size_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
____
|
.______ __ .___________..___ ___. ___ .______
|
||||||
/ ___| ___ _ __ ___ ___ _ __
|
| _ \ | | | || \/ | / \ | _ \
|
||||||
\___ \ / __| '__/ _ \/ _ \ '_ \
|
| |_) | | | `---| |----`| \ / | / ^ \ | |_) |
|
||||||
___) | (__| | | __/ __/ | | |
|
| _ < | | | | | |\/| | / /_\ \ | ___/
|
||||||
|____/ \___|_| \___|\___|_| |_|
|
| |_) | | | | | | | | | / _____ \ | |
|
||||||
|
|______/ |__| |__| |__| |__| /__/ \__\ | _|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
____ __ ____ __ .__ __. _______ ______ ____ __ ____
|
||||||
|
\ \ / \ / / | | | \ | | | \ / __ \ \ \ / \ / /
|
||||||
|
\ \/ \/ / | | | \| | | .--. | | | | \ \/ \/ /
|
||||||
|
\ / | | | . ` | | | | | | | | \ /
|
||||||
|
\ /\ / | | | |\ | | '--' | `--' | \ /\ /
|
||||||
|
\__/ \__/ |__| |__| \__| |_______/ \______/ \__/ \__/
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func GetPixelColor(x, y C.size_t) string {
|
/*
|
||||||
color := C.agetPixelColor(x, y)
|
------------ --- --- ------------ ---- ---- ------------
|
||||||
gcolor := C.GoString(color)
|
************ *** *** ************ ***** **** ************
|
||||||
defer C.free(unsafe.Pointer(color))
|
---- --- --- ---- ------ ---- ------------
|
||||||
return gcolor
|
************ *** *** ************ ************ ****
|
||||||
}
|
------------ --- --- ------------ ------------ ----
|
||||||
|
**** ******** **** **** ****** ****
|
||||||
|
------------ ------ ------------ ---- ----- ----
|
||||||
|
************ **** ************ **** **** ****
|
||||||
|
|
||||||
func GetScreenSize() (C.size_t, C.size_t) {
|
*/
|
||||||
size := C.agetScreenSize()
|
|
||||||
// Println("...", size, size.width)
|
|
||||||
return size.width, size.height
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetXDisplayName() string {
|
|
||||||
name := C.agetXDisplayName()
|
|
||||||
gname := C.GoString(name)
|
|
||||||
defer C.free(unsafe.Pointer(name))
|
|
||||||
return gname
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetXDisplayName(name string) string {
|
|
||||||
cname := C.CString(name)
|
|
||||||
str := C.asetXDisplayName(cname)
|
|
||||||
gstr := C.GoString(str)
|
|
||||||
return gstr
|
|
||||||
}
|
|
||||||
|
|
||||||
func CaptureScreen(x, y, w, h C.int) {
|
|
||||||
bit := C.acaptureScreen(x, y, w, h)
|
|
||||||
Println("...", bit)
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user