Move (相当于 MoveMouse)
MoveSmooth (相当与 MoveMouseSmooth)
Click (相当于 MouseClick)
Drag (相当于 DragMouse)
获取 robotgo 版本
This is a work in progress. (工作正在进行中)
This is a work in progress.
设置键盘延迟 (在键盘一个事件后), 单位 ms, 默认值 10ms
Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.
延迟时间,单位 ms
ms - Time to sleep in milliseconds.
模拟键盘按键
Press a single key.
键盘值
修饰值 (可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift.
key - See keys.
modifier (optional, string or array) - Accepts alt, command (win), control, and shift.
robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
键盘切换, 按住或释放一个键位
Hold down or release a key.
key - See keys.
down - Accepts 'down' or 'up'.
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.
返回 KeyToggle 状态
string - The string to send.
string - The string to send.
cpm - Characters per minute.
text string
text,
error
设置鼠标延迟 (在一个鼠标事件后), 单位 ms, 默认值 10 ms
Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.
ms - Time to sleep in milliseconds.
移动鼠标
Moves mouse to x, y instantly, with the mouse button up.
x, y
// Move the mouse to 100, 100 on the screen.
robotgo.MoveMouse(100, 100)
模拟鼠标向 X,Y 平滑移动(像人类一样),用鼠标按钮向上
Moves mouse to x, y human like, with the mouse button up.
x, y
lowspeed, highspeed
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
鼠标点击
Clicks the mouse.
button (optional) - Accepts left, right, or center. Defaults to left.
double (optional) - Set to true to perform a double click. Defaults to false.
robotgo.MouseClick()
robotgo.MouseClick("left", true)
移动并点击鼠标
x,
y,
button (optional) - Accepts "left", "right", or "center". Defaults to left.
double (optional) - Set to true to perform a double click. Defaults to false.
robotgo.MoveClick(10, 20)
robotgo.MoveClick(10, 20, "left", true)
鼠标切换
Toggles mouse button.
down (optional) - Accepts down or up. Defaults to down.
button (optional) - Accepts "left", "right", or "center". Defaults to left.
robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right")
拖动鼠标
Moves mouse to x, y instantly, with the mouse button held down.
x, y
// Mouse down at 0, 0 and then drag to 100, 100 and release.
robotgo.MoveMouse(0, 0)
robotgo.MouseToggle("down")
robotgo.DragMouse(100, 100)
robotgo.MouseToggle("up")
获取鼠标的位置
Gets the mouse coordinates.
Returns an object with keys x and y.
x, y := robotgo.GetMousePos()
fmt.Println("pos:", x, y)
滚动鼠标
Scrolls the mouse either up or down.
滚动位置的大小
滚动方向: up (向上滚动) down (向下滚动)
magnitude - The amount to scroll.
direction - Accepts down or up.
robotgo.ScrollMouse(50, "up")
robotgo.ScrollMouse(50, "down")
获取坐标为 x, y 位置处的颜色
Gets the pixel color at x, y. This function is perfect for getting a pixel or two,
but if you'll be reading large portions of the screen use screen.capture.
x, y
Returns the hex color code of the pixel at x, y.
获取屏幕大小
Gets the screen width and height.
Returns an object with .width and .height.
// CaptureScreen
获取部分或者全部屏幕
Gets part or all of the screen.
GoCaptureScreen Returns a go struct
x (optional)
y (optional)
height (optional)
width (optional)
If no arguments are provided, capturescreen(screencapture) will get the full screen.
返回一个 bitmap object.
This is a work in progress.
查找 bitmap.
bitmap;
rect (可选参数): x, y, w, h
查找到, 返回 bitmap 的 x 和y 坐标; 没有返回 nil
打开 bitmap 图片.
bitmap 图片路径,
MMImageType (可选)
返回一个 bitmap 对象
保存一个 bitmap 图片.
bitmap 对象,
保存路径,
imagetype (int)
保存图片, 返回保存状态
将一个 bitmap 对象转换为字符串对象.
bitmap 对象
返回一个 bitmap 字符串
bitmap from a portion
bitmap,
rect: x, y, w, h
Returns new bitmap object created from a portion of another
转换 bitmap 图片格式
openpath,
savepath,
MMImageType (可选)
robotgo.Convert("test.png", "test.tif")
FreeBitmap free and dealloc bitmap
MMBitmapRef
robotgo.FreeBitmap(bitmap)
ReadBitmap returns false and sets error if |bitmap| is NULL
MMBitmapRef
bool
robotgo.ReadBitmap(bitmap)
CopyBitpb copy bitmap to pasteboard
MMBitmapRef
bool
robotgo.CopyBitpb(bitmap)
DeepCopyBit deep copy bitmap
MMBitmapRef
MMBitmapRef
robotgo.DeepCopyBit(bitmap)
监听全局事件
string
(鼠标参数: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)
监听成功返回 0
package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
keve := robotgo.AddEvent("k")
if keve {
fmt.Println("you press...", "k")
}
mleft := robotgo.AddEvent("mleft")
if mleft {
fmt.Println("you press...", "mouse left button")
}
}
停止事件监听
Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed
title (string),
msg (string),
defaultButton (optional string),
cancelButton (optional string)
Returns 0 (True) if the default button was pressed, or 1 (False) if cancelled.
关闭窗口
无
无
Valid the Window
无
如果窗口 selected 返回 true
设为当前窗口
hwnd
void
获取当前窗口
无
Returns hwnd
Set the Window Handle
int
bool
获取窗口 Handle
无
Returns hwnd
获取窗口标题
返回窗口标题
获取进程 id
无
返回进程 id
获取所有进程 id
无
返回进程 id
判断进程 id 是否存在
pid
返回 bool
Process get the all process struct
无
Returns []Nps, error
FindName find the process name by the process id
pid
Returns string, error
FindNames find the all process name
none
Returns []string, error
FindIds find the process id by the process name
name string
Returns []int32, error
ActivePID window active by PID
pid int32
none