Update godoc and md

This commit is contained in:
vCaesar 2017-01-17 18:50:54 +08:00
parent 8948a606b3
commit 91afdb28e2
2 changed files with 51 additions and 46 deletions

View File

@ -205,4 +205,9 @@ func main() {
##Future ##Future
- Update Find an image on screen, read pixels from an image - Update Find an image on screen, read pixels from an image
- Update Window Handle - Update Window Handle
- Try support Android,maybe support IOS. - Try support Android,maybe support IOS.
##Contributors
- See [contributors page](https://github.com/go-vgo/robotgo/graphs/contributors) for full list of contributors.
- See [Contribution Guidelines](https://github.com/go-vgo/robotgo/blob/master/CONTRIBUTING.md).

View File

@ -39,7 +39,7 @@ import (
) )
const ( const (
version string = "v0.42.0.210,Mount Ngauruhoe!" version string = "v0.42.0.216,Mount Ngauruhoe!"
) )
//GetVersion get version //GetVersion get version
@ -57,8 +57,8 @@ func GetVersion() string {
*/ */
//Bitmap is Bitmap struct //Bitmap is Bitmap struct
// type Bit_map struct {
type Bitmap struct { type Bitmap struct {
// type Bit_map struct {
ImageBuffer *uint8 ImageBuffer *uint8
Width int Width int
Height int Height int
@ -67,7 +67,7 @@ type Bitmap struct {
BytesPerPixel uint8 BytesPerPixel uint8
} }
//GetPixelColor Get Pixel Color //GetPixelColor Get pixel color
func GetPixelColor(x, y int) string { func GetPixelColor(x, y int) string {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
@ -78,14 +78,14 @@ func GetPixelColor(x, y int) string {
return gcolor return gcolor
} }
//GetScreenSize Get Screen Size //GetScreenSize Get screen size
func GetScreenSize() (int, int) { func GetScreenSize() (int, int) {
size := C.aGetScreenSize() size := C.aGetScreenSize()
// Println("...", size, size.width) // Println("...", size, size.width)
return int(size.width), int(size.height) return int(size.width), int(size.height)
} }
//SetXDisplayName Set XDisplay Name //SetXDisplayName Set XDisplay name
func SetXDisplayName(name string) string { func SetXDisplayName(name string) string {
cname := C.CString(name) cname := C.CString(name)
str := C.aSetXDisplayName(cname) str := C.aSetXDisplayName(cname)
@ -94,7 +94,7 @@ func SetXDisplayName(name string) string {
return gstr return gstr
} }
//GetXDisplayName Get XDisplay Name //GetXDisplayName Get XDisplay name
func GetXDisplayName() string { func GetXDisplayName() string {
name := C.aGetXDisplayName() name := C.aGetXDisplayName()
gname := C.GoString(name) gname := C.GoString(name)
@ -102,7 +102,7 @@ func GetXDisplayName() string {
return gname return gname
} }
//CaptureScreen Capture the Screen //CaptureScreen Capture the screen return bitmap(c struct)
func CaptureScreen(args ...int) C.MMBitmapRef { func CaptureScreen(args ...int) C.MMBitmapRef {
var x C.size_t var x C.size_t
var y C.size_t var y C.size_t
@ -129,9 +129,9 @@ func CaptureScreen(args ...int) C.MMBitmapRef {
return bit return bit
} }
//BCaptureScreen Capture the Screen //BCaptureScreen Capture the screen and return bitmap(go struct)
// func Capture_Screen(args ...int) Bitmap {
func BCaptureScreen(args ...int) Bitmap { func BCaptureScreen(args ...int) Bitmap {
// func Capture_Screen(args ...int) Bitmap {
var x C.size_t var x C.size_t
var y C.size_t var y C.size_t
var w C.size_t var w C.size_t
@ -184,36 +184,36 @@ type MPoint struct {
y int y int
} }
//MoveMouse Move the Mouse //MoveMouse Move the mouse
//C.size_t int
func MoveMouse(x, y int) { func MoveMouse(x, y int) {
//C.size_t int
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
C.aMoveMouse(cx, cy) C.aMoveMouse(cx, cy)
} }
//Move Move the Mouse //Move Move the mouse
func Move(x, y int) { func Move(x, y int) {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
C.aMoveMouse(cx, cy) C.aMoveMouse(cx, cy)
} }
//DragMouse Drag the Mouse //DragMouse Drag the mouse
func DragMouse(x, y int) { func DragMouse(x, y int) {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
C.aDragMouse(cx, cy) C.aDragMouse(cx, cy)
} }
//Drag Drag the Mouse //Drag Drag the mouse
func Drag(x, y int) { func Drag(x, y int) {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
C.aDragMouse(cx, cy) C.aDragMouse(cx, cy)
} }
//MoveMouseSmooth Move the Mouse Smooth //MoveMouseSmooth Move the mouse smooth
func MoveMouseSmooth(x, y int, args ...float64) { func MoveMouseSmooth(x, y int, args ...float64) {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
@ -235,7 +235,7 @@ func MoveMouseSmooth(x, y int, args ...float64) {
C.aMoveMouseSmooth(cx, cy, low, high) C.aMoveMouseSmooth(cx, cy, low, high)
} }
//MoveSmooth Move the Mouse Smooth //MoveSmooth Move the mouse smooth
func MoveSmooth(x, y int, args ...float64) { func MoveSmooth(x, y int, args ...float64) {
cx := C.size_t(x) cx := C.size_t(x)
cy := C.size_t(y) cy := C.size_t(y)
@ -257,7 +257,7 @@ func MoveSmooth(x, y int, args ...float64) {
C.aMoveMouseSmooth(cx, cy, low, high) C.aMoveMouseSmooth(cx, cy, low, high)
} }
//GetMousePos Get Mouse Portion //GetMousePos Get mouse portion
func GetMousePos() (int, int) { func GetMousePos() (int, int) {
pos := C.aGetMousePos() pos := C.aGetMousePos()
// Println("pos:###", pos, pos.x, pos.y) // Println("pos:###", pos, pos.x, pos.y)
@ -267,7 +267,7 @@ func GetMousePos() (int, int) {
return x, y return x, y
} }
//MouseClick Click the Mouse //MouseClick Click the mouse
func MouseClick(args ...interface{}) { func MouseClick(args ...interface{}) {
var button C.MMMouseButton var button C.MMMouseButton
var double C.bool var double C.bool
@ -291,7 +291,7 @@ func MouseClick(args ...interface{}) {
C.aMouseClick(button, double) C.aMouseClick(button, double)
} }
//Click Click the Mouse //Click Click the mouse
func Click(args ...interface{}) { func Click(args ...interface{}) {
var button C.MMMouseButton var button C.MMMouseButton
var double C.bool var double C.bool
@ -315,13 +315,13 @@ func Click(args ...interface{}) {
C.aMouseClick(button, double) C.aMouseClick(button, double)
} }
//MoveClick move and click the Mouse //MoveClick move and click the mouse
func MoveClick(x, y int, args ...interface{}) { func MoveClick(x, y int, args ...interface{}) {
MoveMouse(x, y) MoveMouse(x, y)
MouseClick(args) MouseClick(args)
} }
//MouseToggle Toggle the Mouse //MouseToggle Toggle the mouse
func MouseToggle(args ...interface{}) { func MouseToggle(args ...interface{}) {
var button C.MMMouseButton var button C.MMMouseButton
Try(func() { Try(func() {
@ -344,13 +344,13 @@ func MouseToggle(args ...interface{}) {
defer C.free(unsafe.Pointer(down)) defer C.free(unsafe.Pointer(down))
} }
//SetMouseDelay Set Mouse Delay //SetMouseDelay Set mouse delay
func SetMouseDelay(x int) { func SetMouseDelay(x int) {
cx := C.size_t(x) cx := C.size_t(x)
C.aSetMouseDelay(cx) C.aSetMouseDelay(cx)
} }
//ScrollMouse Scroll the Mouse //ScrollMouse Scroll the mouse
func ScrollMouse(x int, y string) { func ScrollMouse(x int, y string) {
cx := C.size_t(x) cx := C.size_t(x)
z := C.CString(y) z := C.CString(y)
@ -435,7 +435,7 @@ func KeyTap(args ...interface{}) {
} }
//KeyToggle Toggle the Keyboard //KeyToggle Toggle the keyboard
func KeyToggle(args ...string) string { func KeyToggle(args ...string) string {
var adown string var adown string
var amkey string var amkey string
@ -476,14 +476,14 @@ func KeyToggle(args ...string) string {
return C.GoString(str) return C.GoString(str)
} }
//TypeString Type String //TypeString Type string
func TypeString(x string) { func TypeString(x string) {
cx := C.CString(x) cx := C.CString(x)
C.aTypeString(cx) C.aTypeString(cx)
defer C.free(unsafe.Pointer(cx)) defer C.free(unsafe.Pointer(cx))
} }
//TypeStrDelay Type String Delayed //TypeStrDelay Type string delayed
func TypeStrDelay(x string, y int) { func TypeStrDelay(x string, y int) {
cx := C.CString(x) cx := C.CString(x)
cy := C.size_t(y) cy := C.size_t(y)
@ -491,7 +491,7 @@ func TypeStrDelay(x string, y int) {
defer C.free(unsafe.Pointer(cx)) defer C.free(unsafe.Pointer(cx))
} }
//TypeStringDelayed Type String Delayed //TypeStringDelayed Type string delayed
func TypeStringDelayed(x string, y int) { func TypeStringDelayed(x string, y int) {
cx := C.CString(x) cx := C.CString(x)
cy := C.size_t(y) cy := C.size_t(y)
@ -499,12 +499,12 @@ func TypeStringDelayed(x string, y int) {
defer C.free(unsafe.Pointer(cx)) defer C.free(unsafe.Pointer(cx))
} }
//SetKeyDelay Set Keyboard Delay //SetKeyDelay Set keyboard delay
func SetKeyDelay(x int) { func SetKeyDelay(x int) {
C.aSetKeyboardDelay(C.size_t(x)) C.aSetKeyboardDelay(C.size_t(x))
} }
//SetKeyboardDelay Set Keyboard Delay //SetKeyboardDelay Set keyboard delay,Wno-deprecated
func SetKeyboardDelay(x int) { func SetKeyboardDelay(x int) {
C.aSetKeyboardDelay(C.size_t(x)) C.aSetKeyboardDelay(C.size_t(x))
} }
@ -518,7 +518,7 @@ func SetKeyboardDelay(x int) {
|______/ |__| |__| |__| |__| /__/ \__\ | _| |______/ |__| |__| |__| |__| /__/ \__\ | _|
*/ */
//FindBitmap Find the Bitmap //FindBitmap Find the bitmap
func FindBitmap(args ...interface{}) (int, int) { func FindBitmap(args ...interface{}) (int, int) {
var bit C.MMBitmapRef var bit C.MMBitmapRef
bit = args[0].(C.MMBitmapRef) bit = args[0].(C.MMBitmapRef)
@ -542,7 +542,7 @@ func FindBitmap(args ...interface{}) (int, int) {
return int(pos.x), int(pos.y) return int(pos.x), int(pos.y)
} }
//OpenBitmap Open the Bitmap //OpenBitmap Open the bitmap
func OpenBitmap(args ...interface{}) C.MMBitmapRef { func OpenBitmap(args ...interface{}) C.MMBitmapRef {
path := C.CString(args[0].(string)) path := C.CString(args[0].(string))
var mtype C.uint16_t var mtype C.uint16_t
@ -559,7 +559,7 @@ func OpenBitmap(args ...interface{}) C.MMBitmapRef {
// defer C.free(unsafe.Pointer(path)) // defer C.free(unsafe.Pointer(path))
} }
//SaveBitmap Save the Bitmap //SaveBitmap Save the bitmap
func SaveBitmap(args ...interface{}) string { func SaveBitmap(args ...interface{}) string {
var mtype C.uint16_t var mtype C.uint16_t
Try(func() { Try(func() {
@ -586,7 +586,7 @@ func SaveBitmap(args ...interface{}) string {
// // defer C.free(unsafe.Pointer(path)) // // defer C.free(unsafe.Pointer(path))
// } // }
//TostringBitmap Tostring Bitmap //TostringBitmap Tostring bitmap
func TostringBitmap(bit C.MMBitmapRef) *C.char { func TostringBitmap(bit C.MMBitmapRef) *C.char {
// str_bit := C.aTostringBitmap(bit) // str_bit := C.aTostringBitmap(bit)
strBit := C.aTostringBitmap(bit) strBit := C.aTostringBitmap(bit)
@ -595,7 +595,7 @@ func TostringBitmap(bit C.MMBitmapRef) *C.char {
return strBit return strBit
} }
//GetPortion Get Portion //GetPortion Get portion
func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef { func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
var rect C.MMRect var rect C.MMRect
rect.origin.x = x rect.origin.x = x
@ -639,7 +639,7 @@ func Convert(args ...interface{}) {
//Map a map //Map a map
type Map map[string]interface{} type Map map[string]interface{}
//AddEvent Add Event //AddEvent Add event listener
func AddEvent(aeve string) int { func AddEvent(aeve string) int {
keycode := Map{ keycode := Map{
"f1": "59", "f1": "59",
@ -674,12 +674,12 @@ func AddEvent(aeve string) int {
return geve return geve
} }
//StopEvent Stop Event //StopEvent Stop event listener
func StopEvent() { func StopEvent() {
C.aStop() C.aStop()
} }
//LEvent Add Event //LEvent Add event listener,Wno-deprecated
func LEvent(aeve string) int { func LEvent(aeve string) int {
cs := C.CString(aeve) cs := C.CString(aeve)
eve := C.aEvent(cs) eve := C.aEvent(cs)
@ -699,7 +699,7 @@ ____ __ ____ __ .__ __. _______ ______ ____ __ ____
*/ */
//ShowAlert Show a Alert Window //ShowAlert Show a alert window
func ShowAlert(title, msg string, args ...string) int { func ShowAlert(title, msg string, args ...string) int {
var ( var (
// title string // title string
@ -731,7 +731,7 @@ func ShowAlert(title, msg string, args ...string) int {
return ibool return ibool
} }
//IsValid Valid the Window //IsValid Valid the window
func IsValid() bool { func IsValid() bool {
abool := C.aIsValid() abool := C.aIsValid()
gbool := bool(abool) gbool := bool(abool)
@ -739,30 +739,30 @@ func IsValid() bool {
return gbool return gbool
} }
//SetActive Set the Window Active //SetActive Set the window active
func SetActive(win C.MData) { func SetActive(win C.MData) {
C.aSetActive(win) C.aSetActive(win)
} }
//GetActive Get the Active Window //GetActive Get the active window
func GetActive() C.MData { func GetActive() C.MData {
mdata := C.aGetActive() mdata := C.aGetActive()
// Println("active----", mdata) // Println("active----", mdata)
return mdata return mdata
} }
//CloseWindow Close the Window //CloseWindow Close the window
func CloseWindow() { func CloseWindow() {
C.aCloseWindow() C.aCloseWindow()
} }
//SetHandle Set the Window Handle //SetHandle Set the window handle
func SetHandle(hwnd int) { func SetHandle(hwnd int) {
chwnd := C.uintptr(hwnd) chwnd := C.uintptr(hwnd)
C.aSetHandle(chwnd) C.aSetHandle(chwnd)
} }
//GetHandle Get the Window Handle //GetHandle Get the window handle
func GetHandle() int { func GetHandle() int {
hwnd := C.aGetHandle() hwnd := C.aGetHandle()
ghwnd := int(hwnd) ghwnd := int(hwnd)
@ -770,7 +770,7 @@ func GetHandle() int {
return ghwnd return ghwnd
} }
//GetTitle Get the Window Title //GetTitle Get the window title
func GetTitle() string { func GetTitle() string {
title := C.aGetTitle() title := C.aGetTitle()
gtittle := C.GoString(title) gtittle := C.GoString(title)