mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-06 08:43:56 +00:00
Update godoc
This commit is contained in:
parent
7f3b43e47d
commit
a5173b5b54
88
robotgo.go
88
robotgo.go
@ -79,7 +79,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)
|
||||||
@ -90,14 +90,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()
|
||||||
// fmt.Println("...", size, size.width)
|
// fmt.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)
|
||||||
@ -106,7 +106,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)
|
||||||
@ -114,7 +114,7 @@ func GetXDisplayName() string {
|
|||||||
return gname
|
return gname
|
||||||
}
|
}
|
||||||
|
|
||||||
// CaptureScreen Capture the screen return bitmap(c struct)
|
// 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
|
||||||
@ -141,7 +141,7 @@ func CaptureScreen(args ...int) C.MMBitmapRef {
|
|||||||
return bit
|
return bit
|
||||||
}
|
}
|
||||||
|
|
||||||
// BCaptureScreen Capture the screen and return bitmap(go struct)
|
// BCaptureScreen capture the screen and return bitmap(go struct)
|
||||||
func BCaptureScreen(args ...int) Bitmap {
|
func BCaptureScreen(args ...int) Bitmap {
|
||||||
var x C.size_t
|
var x C.size_t
|
||||||
var y C.size_t
|
var y C.size_t
|
||||||
@ -193,7 +193,7 @@ type MPoint struct {
|
|||||||
y int
|
y int
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveMouse Move the mouse
|
// MoveMouse move the mouse
|
||||||
func MoveMouse(x, y int) {
|
func MoveMouse(x, y int) {
|
||||||
//C.size_t int
|
//C.size_t int
|
||||||
cx := C.size_t(x)
|
cx := C.size_t(x)
|
||||||
@ -201,28 +201,28 @@ func MoveMouse(x, y int) {
|
|||||||
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)
|
||||||
@ -244,7 +244,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)
|
||||||
@ -266,7 +266,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()
|
||||||
// fmt.Println("pos:###", pos, pos.x, pos.y)
|
// fmt.Println("pos:###", pos, pos.x, pos.y)
|
||||||
@ -276,7 +276,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
|
||||||
@ -300,7 +300,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
|
||||||
@ -330,7 +330,7 @@ func MoveClick(x, y int, args ...interface{}) {
|
|||||||
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() {
|
||||||
@ -353,13 +353,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)
|
||||||
@ -387,7 +387,7 @@ func Try(fun func(), handler func(interface{})) {
|
|||||||
fun()
|
fun()
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyTap Tap the keyboard;
|
// KeyTap tap the keyboard;
|
||||||
//
|
//
|
||||||
// See keys:
|
// See keys:
|
||||||
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
||||||
@ -447,7 +447,7 @@ func KeyTap(args ...interface{}) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyToggle Toggle the keyboard
|
// KeyToggle toggle the keyboard
|
||||||
//
|
//
|
||||||
// See keys:
|
// See keys:
|
||||||
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
// https://github.com/go-vgo/robotgo/blob/master/docs/keys.md
|
||||||
@ -491,14 +491,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)
|
||||||
@ -506,7 +506,7 @@ func TypeStrDelay(x string, y int) {
|
|||||||
defer C.free(unsafe.Pointer(cx))
|
defer C.free(unsafe.Pointer(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeStringDelayed Type string delayed, Wno-deprecated
|
// TypeStringDelayed type string delayed, Wno-deprecated
|
||||||
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)
|
||||||
@ -514,12 +514,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, Wno-deprecated
|
// 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))
|
||||||
}
|
}
|
||||||
@ -533,7 +533,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)
|
||||||
@ -557,7 +557,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
|
||||||
@ -574,7 +574,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() {
|
||||||
@ -601,7 +601,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)
|
||||||
@ -610,7 +610,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
|
||||||
@ -622,7 +622,7 @@ func GetPortion(bit C.MMBitmapRef, x, y, w, h C.size_t) C.MMBitmapRef {
|
|||||||
return pos
|
return pos
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert Convert bitmap
|
// Convert convert bitmap
|
||||||
func Convert(args ...interface{}) {
|
func Convert(args ...interface{}) {
|
||||||
var mtype int
|
var mtype int
|
||||||
Try(func() {
|
Try(func() {
|
||||||
@ -670,7 +670,7 @@ func CopyBitpb(bitmap C.MMBitmapRef) bool {
|
|||||||
// Map a map
|
// Map a map
|
||||||
type Map map[string]interface{}
|
type Map map[string]interface{}
|
||||||
|
|
||||||
// AddEvent Add event listener
|
// AddEvent add event listener
|
||||||
func AddEvent(aeve string) int {
|
func AddEvent(aeve string) int {
|
||||||
keycode := Map{
|
keycode := Map{
|
||||||
"f1": "59",
|
"f1": "59",
|
||||||
@ -705,12 +705,12 @@ func AddEvent(aeve string) int {
|
|||||||
return geve
|
return geve
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopEvent Stop event listener
|
// StopEvent stop event listener
|
||||||
func StopEvent() {
|
func StopEvent() {
|
||||||
C.aStop()
|
C.aStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LEvent Add event listener, Wno-deprecated
|
// 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)
|
||||||
@ -730,7 +730,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
|
||||||
@ -762,7 +762,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)
|
||||||
@ -770,30 +770,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()
|
||||||
// fmt.Println("active----", mdata)
|
// fmt.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)
|
||||||
@ -801,7 +801,7 @@ func GetHandle() int {
|
|||||||
return ghwnd
|
return ghwnd
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBHandle Get the window handle
|
// GetBHandle get the window handle
|
||||||
func GetBHandle() int {
|
func GetBHandle() int {
|
||||||
hwnd := C.bGetHandle()
|
hwnd := C.bGetHandle()
|
||||||
ghwnd := int(hwnd)
|
ghwnd := int(hwnd)
|
||||||
@ -809,7 +809,7 @@ func GetBHandle() 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)
|
||||||
@ -817,7 +817,7 @@ func GetTitle() string {
|
|||||||
return gtittle
|
return gtittle
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPID Get the process id
|
// GetPID get the process id
|
||||||
func GetPID() int {
|
func GetPID() int {
|
||||||
pid := C.aGetPID()
|
pid := C.aGetPID()
|
||||||
return int(pid)
|
return int(pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user