From 65bc4cbae78023b8ebe63ef7ead9f179af19ce7c Mon Sep 17 00:00:00 2001 From: vCaesar Date: Sat, 15 Oct 2016 19:43:58 +0800 Subject: [PATCH] Update screen --- robotgo.go | 120 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 35 deletions(-) diff --git a/robotgo.go b/robotgo.go index 9ae2dc4..0119e41 100644 --- a/robotgo.go +++ b/robotgo.go @@ -23,6 +23,66 @@ import ( // "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) -} +*/