robotgo
17 分钟阅读
原文:https://pkg.go.dev/github.com/go-vgo/robotgo
收录该文档时间:
2025-04-18T09:26:20+08:00版本:v0.110.7
Published: Apr 11, 2025
Golang Desktop Automation. Control the mouse, keyboard, read the screen, process, Window Handle, image and bitmap and global event listener.
Golang 桌面自动化。控制鼠标、键盘、读取屏幕、进程、窗口句柄、图像和位图以及全局事件监听器。
RobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x86-amd64.
RobotGo 支持 macOS、Windows 和 Linux(X11);并且兼容 arm64 和 x86‑amd64 架构。
Docs
Binding
ADB, packaging android adb API.
Robotn, binding JavaScript and other, support more language.
Robotn,绑定 JavaScript 等语言,支持更多语言调用。
Requirements
Now, Please make sure Golang, GCC is installed correctly before installing RobotGo.
请在安装 RobotGo 之前,确保已正确安装 Golang 和 GCC。
ALL:
| |
For MacOS:
| |
Xcode Command Line Tools (And Privacy setting: #277)
安装 Xcode 命令行工具(及隐私设置见 #277):
| |
For Windows:
| |
Or MinGW-w64 (Use recommended) or others Mingw llvm-mingw;
Download the Mingw, then set system environment variables C:\mingw64\bin to the Path. Set environment variables to run GCC from command line.
或使用 MinGW-w64(推荐)或其他如 llvm-mingw;
下载后将 `C:\mingw64\bin` 添加到系统环境变量 Path。详细设置请参考 “[Set environment variables to run GCC from command line]”。
Or the other GCC (But you should compile the “libpng” with yourself when use the bitmap.)
或者使用其他 GCC,但在使用 bitmap 时需自行编译 “libpng”。
For everything else:
| |
Ubuntu:
| |
Fedora:
| |
Installation:
With Go module support (Go 1.11+), just import:
在支持 Go module(Go 1.11 及以上)的项目中,只需导入:
| |
Otherwise, to install the robotgo package, run the command:
| |
png.h: No such file or directory? Please see issues/47.
如出现 “png.h: No such file or directory” 错误,请参考 issues/47。
Update:
| |
Note go1.10.x C file compilation cache problem, golang #24355. go mod vendor problem, golang #26366.
注意 go1.10.x 的 C 文件编译缓存问题,见 [golang/go#24355];go mod vendor 问题,见 [golang/go#26366]。
Examples
Mouse
| |
Keyboard
| |
Screen
| |
Bitmap
| |
OpenCV
| |
Event
| |
Window
| |
Authors
Plans
- Refactor some C code to Go (such as x11, windows) 将部分 C 代码重构为 Go(例如 x11、Windows)
- Better multiscreen support 更完善的多屏支持
- Wayland support
- Update Window Handle
- Try to support Android and IOS 尝试支持 Android 和 iOS
Contributors
- See contributors page for full list of contributors.
- See Contribution Guidelines.
License
Robotgo is primarily distributed under the terms of “both the MIT license and the Apache License (Version 2.0)”, with portions covered by various BSD-like licenses.
See LICENSE-APACHE, LICENSE-MIT.
Collapse ▴
Overview
Package robotgo Go native cross-platform system automation.
robotgo 包是 Go 原生的跨平台系统自动化库。
Please make sure Golang, GCC is installed correctly before installing RobotGo;
请在安装 RobotGo 之前,确保已正确安装 Golang 和 GCC;
See Requirements:
请查看安装要求:
| |
Installation:
With Go module support (Go 1.11+), just import:
在支持 Go module(Go 1.11 及以上)的项目中,只需导入:
| |
Otherwise, to install the robotgo package, run the command:
否则,可运行以下命令安装:
| |
+bulid linux,next
+bulid windows,next
常量
| |
Defining a bunch of constants.
| |
| |
变量
| |
| |
Keycode robotgo hook key’s code map
| |
MouseMap robotgo hook mouse’s code map
| |
Special is the special key map
函数
func ActiveName
| |
ActiveName active the window by name
ActiveName 根据窗口名称激活对应窗口
Examples:
| |
func ActivePid ← 0.110.0
| |
ActivePid active the window by Pid, If args[0] > 0 on the Windows platform via a window handle to active, If args[0] > 0 on the unix platform via a xid to active ActivePid 根据进程 PID 激活窗口, 若 args[0] > 0,则在 Windows 上通过窗口句柄激活,在 Unix 上通过 XID 激活。
func ActivePidC ← 0.110.0
| |
ActivePidC active the window by Pid, If args[0] > 0 on the unix platform via a xid to active
ActivePidC 根据 PID 激活窗口,Unix 平台若 args[0] > 0 则通过 XID 激活。
func Alert ← 0.110.0
| |
Alert show a alert window Displays alert with the attributes. If cancel button is not given, only the default button is displayed
Alert 显示一个原生弹窗,参数可指定标题、内容及按钮;若未传入取消按钮,则仅显示默认按钮。
Examples
| |
func ByteToImg ← 0.93.2
| |
ByteToImg convert []byte to image.Image
ByteToImg 将字节切片转换为 image.Image。
func Capture ← 0.110.0
| |
Capture capture the screenshot, use the CaptureImg default
Capture 抓取屏幕到 RGBA,等同于默认使用 CaptureImg。
func CaptureImg ← 0.100.1
| |
CaptureImg capture the screen and return image.Image, error
CaptureImg 抓取屏幕并返回 image.Image。
func CharCodeAt
| |
CharCodeAt char code at utf-8
CharCodeAt 获取 UTF-8 字符串中第 n 个字符的码点。
func CheckMouse
| |
CheckMouse check the mouse button
CheckMouse 检测并返回指定的鼠标按键。
func Click
| |
Click click the mouse button
robotgo.Click(button string, double bool)
Examples
| |
func CloseMainDisplay ← 0.110.3
| |
CloseMainDisplay close the main X11 display
CloseMainDisplay 关闭主 X11 显示器连接。
func CloseWindow
| |
CloseWindow close the window
CloseWindow 关闭指定窗口。
func CmdCtrl ← 0.110.0
| |
CmdCtrl If the operating system is macOS, return the key string “cmd”, otherwise return the key string “ctrl”
CmdCtrl 返回当前系统的主控键,在 macOS 上返回 “cmd”,其它平台返回 “ctrl”。
func DecodeImg
| |
DecodeImg decode the image to image.Image and return
DecodeImg 解码图像文件为 image.Image,并返回格式信息。
func DisplaysNum ← 0.110.0
| |
DisplaysNum get the count of displays
DisplaysNum 获取当前所有显示器的数量。
func Drag ← DEPRECATED
| |
Deprecated: use the DragSmooth(),
Drag drag the mouse to (x, y), It’s not valid now, use the DragSmooth()
已弃用:请使用 DragSmooth();
Drag 在屏幕上拖动鼠标到指定坐标(现已失效)。
func DragMouse ← DEPRECATED
| |
Deprecated: use the DragSmooth(),
DragMouse drag the mouse to (x, y), It’s same with the DragSmooth() now
已弃用:请使用 DragSmooth();
DragMouse 功能同 DragSmooth()。
func DragSmooth
| |
DragSmooth drag the mouse like smooth to (x, y)
DragSmooth 以平滑轨迹拖动鼠标到指定坐标。
Examples
| |
func FindIds
| |
FindIds finds the all processes named with a subset of “name” (case insensitive), return matched IDs.
FindIds 查找所有进程名称中包含指定子串(不区分大小写)的进程,返回匹配的 PID 列表。
func FindName
| |
FindName find the process name by the process id
FindName 根据 PID 查找进程名称
func FindNames
| |
FindNames find the all process name
FindNames 查找所有进程名称
func FindPath
| |
FindPath find the process path by the process pid
FindPath 根据 PID 查找进程可执行文件路径
func FreeBitmap
| |
FreeBitmap free and dealloc the C bitmap
FreeBitmap 释放并回收 CBitmap
func FreeBitmapArr ← 0.100.1
| |
FreeBitmapArr free and dealloc the C bitmap array
FreeBitmapArr 释放并回收多个 CBitmap
func GetActiveC ← 0.110.3
| |
GetActiveC get the active window
GetActiveC 获取当前激活窗口信息
func GetBHandle ← DEPRECATED
| |
Deprecated: use the GetHandle(),
GetBHandle get the window handle, Wno-deprecated
This function will be removed in version v1.0.0
已弃用:请使用 GetHandle()
GetBHandle 返回窗口句柄(将于 v1.0.0 移除)
func GetBounds
| |
GetBounds get the window bounds
GetBounds 获取指定 PID 窗口的边界 (x, y, w, h)
func GetClient ← 0.110.0
| |
GetClient get the window client bounds
GetClient 获取指定 PID 窗口的客户区边界 (x, y, w, h)
func GetDisplayBounds ← 0.110.0
| |
GetDisplayBounds gets the display screen bounds
GetDisplayBounds 获取第 i 个显示器的屏幕边界 (x, y, w, h)
func GetHWNDByPid ← 0.110.0
| |
GetHWNDByPid get the hwnd by pid
GetHWNDByPid 根据 PID 返回 Windows 窗口句柄
func GetHandByPidC ← 0.110.3
| |
GetHandByPidC get handle mdata by pid
GetHandByPidC 根据 PID 返回跨平台窗口句柄数据
func GetHandle
| |
GetHandle get the window handle
GetHandle 获取当前活动窗口的句柄
func GetLocationColor ← 0.110.0
| |
GetLocationColor get the location pos’s color
GetLocationColor 获取当前鼠标位置或指定显示器上某点的像素颜色
func GetMainId ← 0.110.0
| |
GetMainId get the main display id
GetMainId 获取主显示器 ID
func GetMousePos ← DEPRECATED
| |
Deprecated: use the function Location()
GetMousePos get the mouse’s position return x, y
已弃用:请使用 Location() GetMousePos 获取鼠标当前位置 (x, y)
func GetPid ← 0.110.0
| |
GetPid get the process id return int32
GetPid 获取当前进程的 PID
func GetPixelColor
| |
GetPixelColor get the pixel color return string
GetPixelColor 获取指定坐标的像素颜色(十六进制字符串)
func GetPxColor
| |
GetPxColor get the pixel color return C.MMRGBHex
GetPxColor 获取指定坐标的像素颜色(C.MMRGBHex 结构)
func GetScaleSize
| |
GetScaleSize get the screen scale size
GetScaleSize 获取指定显示器的缩放后尺寸 (宽, 高)
func GetScreenSize
| |
GetScreenSize get the screen size
GetScreenSize 获取屏幕分辨率 (宽, 高)
func GetText
| |
GetText get the image text by tesseract ocr
robotgo.GetText(imgPath, lang string)
GetText 使用 Tesseract OCR 识别图像中的文字
robotgo.GetText(imgPath, lang string)
func GetTitle
| |
GetTitle get the window title return string
GetTitle 获取指定窗口或当前活动窗口的标题
Examples:
| |
func GetVersion
| |
GetVersion get the robotgo version
GetVersion 获取 RobotGo 的版本号
func GetXDisplayName
| |
GetXDisplayName get XDisplay name (Linux)
GetXDisplayName 获取 X11 系统的 DISPLAY 名称
func GetXid ← 0.110.0
| |
GetXid get the xid return window and error
GetXid 通过 PID 获取 X11 窗口的 XID
func GetXidFromPid
| |
GetXidFromPid get the xid from pid
GetXidFromPid 同上,通过 PID 获取 XID
func GoString
| |
GoString trans C.char to string
GoString 将 C.char 转换为 Go 字符串
func Height ← 0.100.2
| |
Height return the image.Image height
Height 返回 image.Image 的高度
func HexToRgb
| |
HexToRgb trans hex to rgb
HexToRgb 将十六进制颜色值转换为 RGB
func ImgSize ← 0.100.2
| |
ImgSize get the file image size
ImgSize 获取图像文件的尺寸 (宽, 高)
func Is64Bit
| |
Is64Bit determine whether the sys is 64bit
Is64Bit 判断当前系统是否为 64 位
func IsMain ← 0.110.0
| |
IsMain is main display
IsMain 判断指定显示器是否为主显示器
func IsValid
| |
IsValid valid the window
IsValid 判断当前活动窗口是否有效
func KeyDown ← 0.100.0
| |
KeyDown press down a key
KeyDown 模拟按下指定按键
func KeyPress ← 0.100.0
| |
KeyPress press key string
KeyPress 模拟按键按下并释放
func KeyTap
| |
KeyTap taps the keyboard code;
KeyTap 模拟单击键盘按键;
See keys supported: 支持按键列表见:
https://github.com/go-vgo/robotgo/blob/master/docs/keys.md#keys
Examples:
| |
func KeyToggle
| |
KeyToggle toggles the keyboard, if there not have args default is “down”
KeyToggle 切换按键状态,若未指定状态则默认为 “down”
See keys: https://github.com/go-vgo/robotgo/blob/master/docs/keys.md#keys
Examples:
| |
func KeyUp ← 0.100.0
| |
KeyUp press up a key
KeyUp 模拟释放指定按键
func Kill
| |
Kill kill the process by PID
Kill 通过 PID 杀死进程
func Location ← 0.110.0
| |
Location get the mouse location position return x, y
Location 获取鼠标当前位置,返回 x, y
func MaxWindow
| |
MaxWindow set the window max
MaxWindow 将指定窗口最大化
func MicroSleep DEPRECATED
| |
Deprecated: use the MilliSleep(),
MicroSleep time C.microsleep(tm)
已弃用:请使用 MilliSleep(),
func MilliSleep
| |
MilliSleep sleep tm milli second
MilliSleep 以毫秒为单位暂停 tm 毫秒
func MinWindow
| |
MinWindow set the window min
MinWindow 将指定窗口最小化
func MouseClick ← DEPRECATED
| |
Deprecated: use the Click(),
MouseClick click the mouse
已弃用:请使用 Click(),
MouseClick 单击鼠标
func MouseDown ← 0.110.0
| |
MouseDown send mouse down event
MouseDown 发送鼠标按下事件
func MouseUp ← 0.110.0
| |
MouseUp send mouse up event
MouseUp 发送鼠标抬起事件
func Move
| |
Move move the mouse to (x, y)
Move 将鼠标移动到 (x, y)
Examples:
| |
func MoveArgs
| |
MoveArgs get the mouse relative args
MoveArgs 获取鼠标移动的相对坐标
func MoveClick
| |
MoveClick move and click the mouse
MoveClick 移动鼠标并单击
robotgo.MoveClick(x, y int, button string, double bool)
Examples:
| |
func MoveMouse ← DEPRECATED
| |
Deprecated: use the Move(),
MoveMouse move the mouse
已弃用:请使用 Move(),
MoveMouse 将鼠标移动到指定位置
func MoveMouseSmooth ← DEPRECATED
| |
Deprecated: use the MoveSmooth(),
MoveMouseSmooth move the mouse smooth, moves mouse to x, y human like, with the mouse button up.
已弃用:请使用 MoveSmooth(),
MoveMouseSmooth 平滑移动鼠标到 (x, y)
func MoveRelative
| |
MoveRelative move mouse with relative
MoveRelative 相对移动鼠标
func MoveScale ← 0.110.0
| |
MoveScale calculate the os scale factor x, y
MoveScale 根据系统缩放计算坐标
func MoveSmooth
| |
MoveSmooth move the mouse smooth, moves mouse to x, y human like, with the mouse button up.
MoveSmooth 平滑移动鼠标到 (x, y)
robotgo.MoveSmooth(x, y int, low, high float64, mouseDelay int)
Examples:
| |
func MoveSmoothRelative
| |
MoveSmoothRelative move mouse smooth with relative
MoveSmoothRelative 相对平滑移动鼠标
func MovesClick
| |
MovesClick move smooth and click the mouse
use the robotgo.MouseSleep = 100
MovesClick 平滑移动并单击鼠标
使用 robotgo.MouseSleep = 100
func Mul ← DEPRECATED
| |
Deprecated: use the ScaledF(),
Mul mul the scale, drop
已弃用:请使用 ScaledF(),
Mul 按系统缩放计算,已废弃
func OpenImg
| |
OpenImg open the image return []byte
OpenImg 打开图像并返回[]byte
func PadHex
| |
PadHex trans C.MMRGBHex to string
PadHex 将 C.MMRGBHex 转换为字符串
func PadHexs ← 0.110.0
| |
PadHexs trans CHex to string
PadHexs 将 CHex 转换为字符串
func PasteStr
| |
PasteStr paste a string (support UTF-8), write the string to clipboard and tap cmd + v
PasteStr 粘贴字符串(支持 UTF-8),写入剪贴板并模拟 cmd+v
func PidExists
| |
PidExists determine whether the process exists
PidExists 判断指定 PID 的进程是否存在
func Pids
| |
Pids get the all process id
Pids 获取所有进程的 PID 列表
func Read ← 0.100.0
| |
Read read the file return image.Image
Read 读取图像文件并返回 image.Image
func ReadAll
| |
ReadAll read string from clipboard
ReadAll 从剪贴板读取文本
func RgbToHex
| |
RgbToHex trans rgb to hex
RgbToHex 将 RGB 值转换为十六进制
func Run ← 0.100.9
| |
Run run a cmd shell
Run 在系统 shell 中执行命令并返回输出
func Save ← 0.100.0
| |
Save create a image file with the image.Image
Save 使用 image.Image 创建图像文件,可指定质量
func SaveCapture
| |
SaveCapture capture screen and save the screenshot to image
SaveCapture 捕获屏幕并保存为图像文件
func SaveImg
| |
SaveImg save the image by []byte SaveImg 将字节切片保存为图像文件
func SaveJpeg ← 0.100.0
| |
SaveJpeg save the image by image.Image
SaveJpeg 以 JPEG 格式保存 image.Image
func SavePng ← 0.92.0
| |
SavePng save the image by image.Image
SavePng 以 PNG 格式保存 image.Image
func Scale0 DEPRECATED
| |
Deprecated: use the ScaledF(), Scale0 return ScaleX() / 0.96, drop
已弃用:请使用 ScaledF(),
Scale0 返回 ScaleX()/0.96,已废弃
func Scale1 DEPRECATED
| |
Deprecated: use the ScaledF(), Scale1 get the screen scale (only windows old), drop 已弃用:请使用 ScaledF(), Scale1 获取旧版 Windows 缩放值,已废弃
func ScaleF ← 0.100.8
| |
ScaleF get the system scale val
ScaleF 获取系统缩放值
func ScaleX ← DEPRECATED
| |
Deprecated: use the ScaledF(),
ScaleX get the primary display horizontal DPI scale factor, drop
已弃用:请使用 ScaledF(), ScaleX 获取主显示器水平 DPI 缩放因子,已废弃
func Scaled
| |
Scaled get the screen scaled return scale size
Scaled 根据系统缩放计算并返回缩放后的尺寸
func Scaled0 ← 0.100.8
| |
Scaled0 return int(x * f)
Scaled0 返回 int(x * f)
func Scaled1 ← 0.110.0
| |
Scaled1 return int(x / f)
Scaled1 返回 int(x / f)
func Scroll
| |
Scroll scroll the mouse to (x, y)
Scroll 将鼠标滚动到 (x, y)
robotgo.Scroll(x, y, msDelay int)
Examples:
| |
func ScrollDir ← 0.110.0
| |
ScrollDir scroll the mouse with direction to (x, “up”) supported: “up”, “down”, “left”, “right”
ScrollDir 按方向滚动鼠标,支持:“up”、“down”、“left”、“right”
Examples:
| |
func ScrollRelative ← 0.100.1
| |
ScrollRelative scroll mouse with relative
ScrollRelative 相对滚动鼠标
Examples:
| |
func ScrollSmooth ← 0.100.7
| |
ScrollSmooth scroll the mouse smooth, default scroll 5 times and sleep 100 millisecond
ScrollSmooth 平滑滚动鼠标,默认滚动 5 次并暂停 100 毫秒
robotgo.ScrollSmooth(toy, num, sleep, tox)
Examples:
| |
func SetActive
| |
SetActive set the window active
SetActive 激活指定窗口
func SetActiveC ← 0.110.3
| |
SetActiveC set the window active
SetActiveC 激活指定窗口(跨平台句柄)
func SetDelay
| |
SetDelay sets the key and mouse delay
robotgo.SetDelay(100) option the robotgo.KeySleep and robotgo.MouseSleep = d
SetDelay 设置按键与鼠标延迟
robotgo.SetDelay(延迟毫秒) 同时设置 robotgo.KeySleep 与 robotgo.MouseSleep
func SetHandle
| |
SetHandle set the window handle
SetHandle 设置当前操作的窗口句柄
func SetHandlePid
| |
SetHandlePid set the window handle by pid
SetHandlePid 根据 PID 设置窗口句柄
func SetXDisplayName
| |
SetXDisplayName set XDisplay name (Linux)
SetXDisplayName 设置 X11 DISPLAY 名称(Linux)
func Sleep
| |
Sleep time.Sleep tm second
Sleep 调用 time.Sleep 暂停 tm 秒
func StrToImg ← 0.94.0
| |
StrToImg convert base64 string to image.Image
StrToImg 将 Base64 编码字符串转换为 image.Image
func SysScale
| |
SysScale get the sys scale
SysScale 获取系统缩放因子
func ToByteImg ← 0.94.0
| |
ToByteImg convert image.Image to []byte
ToByteImg 将 image.Image 转换为字节切片
func ToImage ← 0.92.0
| |
ToImage convert C.MMBitmapRef to standard image.Image
ToImage 将 C.MMBitmapRef 转换为标准 image.Image
func ToInterfaces ← 0.110.0
| |
ToInterfaces convert []string to []interface{} ToInterfaces 将 []string 转换为 []interface{}
func ToMMBitmapRef
| |
ToMMBitmapRef trans CBitmap to C.MMBitmapRef
ToMMBitmapRef 将 CBitmap 转换为 C.MMBitmapRef
func ToMMRGBHex
| |
ToMMRGBHex trans CHex to C.MMRGBHex ToMMRGBHex 将 CHex 转换为 C.MMRGBHex
func ToRGBA ← 0.99.9
| |
ToRGBA convert C.MMBitmapRef to standard image.RGBA
ToRGBA 将 C.MMBitmapRef 转换为标准 *image.RGBA
func ToRGBAGo ← 0.99.9
| |
ToRGBAGo convert Bitmap to standard image.RGBA ToRGBAGo 将 Bitmap 转换为标准 *image.RGBA
func ToStringImg ← 0.94.0
| |
ToStringImg convert image.Image to string
ToStringImg 将 image.Image 转换为字符串(Base64 等格式)
func ToStrings ← 0.110.0
| |
ToStrings convert []interface{} to []string
ToStrings 将 []interface{} 转换为 []string
func ToUC ← 0.99.1
| |
ToUC trans string to unicode []string
ToUC 将字符串转换为 Unicode 码点切片
func ToUint8p ← 0.99.9
| |
ToUint8p convert the []uint8 to uint8 pointer
ToUint8p 将 []uint8 转换为 *uint8
func Toggle ← 0.100.7
| |
Toggle toggle the mouse, support button:
Toggle 切换鼠标按键状态,支持按钮:
| |
Examples:
| |
func Try
| |
Try handler(err)
Try 运行 fun 并在发生 panic 时调用 handler(err)
func TypeStr
| |
TypeStr send a string (supported UTF-8)
robotgo.TypeStr(string: “The string to send”, int: pid, “milli_sleep time”, “x11 option”)
Examples:
| |
func TypeStrDelay
| |
TypeStrDelay type string with delayed
And you can use robotgo.KeySleep = 100 to delayed not this function
TypeStrDelay 带延迟地输入字符串
可使用 robotgo.KeySleep = 100 代替此函数进行延迟
func TypeStringDelayed ← DEPRECATED
| |
Deprecated: use the TypeStr(),
TypeStringDelayed type string delayed, Wno-deprecated
This function will be removed in version v1.0.0
已弃用:请使用 TypeStr(),
TypeStringDelayed 延迟输入字符串,已弃用
此函数将在 v1.0.0 移除
func U32ToHex
| |
U32ToHex trans C.uint32_t to C.MMRGBHex
U32ToHex 将 C.uint32_t 转换为 C.MMRGBHex
func U8ToHex
| |
U8ToHex trans *C.uint8_t to C.MMRGBHex
U8ToHex 将 *C.uint8_t 转换为 C.MMRGBHex
func UnicodeType
| |
UnicodeType tap the uint32 unicode
UnicodeType 输入单个 Unicode 码点
func Width ← 0.100.2
| |
Width return the image.Image width
Width 返回 image.Image 的宽度
func WriteAll
| |
WriteAll write string to clipboard
WriteAll 将字符串写入剪贴板
Types
type Bitmap
| |
Bitmap define the go Bitmap struct
Bitmap 定义 Go 端的 Bitmap 结构体
func CaptureGo ← 0.110.0
| |
CaptureGo capture the screen and return bitmap(go struct)
CaptureGo 抓取屏幕并返回 Go 结构体 Bitmap
func ImgToBitmap ← 0.99.9
| |
ImgToBitmap convert the standard image.Image to Bitmap
ImgToBitmap 将标准 image.Image 转换为 Bitmap 结构体
func RGBAToBitmap ← 0.99.9
| |
RGBAToBitmap convert the standard image.RGBA to Bitmap
RGBAToBitmap 将标准 *image.RGBA 转换为 Bitmap 结构体
func ToBitmap
| |
ToBitmap trans C.MMBitmapRef to Bitmap
ToBitmap 将 C.MMBitmapRef 转换为 Bitmap
type CBitmap
| |
CBitmap define CBitmap as C.MMBitmapRef type
CBitmap 定义为 C.MMBitmapRef 类型
func ByteToCBitmap ← 0.110.0
| |
ByteToCBitmap trans []byte to CBitmap
ByteToCBitmap 将 []byte 转换为 CBitmap
func CaptureScreen
| |
CaptureScreen capture the screen return bitmap(c struct), use defer robotgo.FreeBitmap(bitmap) to free the bitmap
robotgo.CaptureScreen(x, y, w, h int)
CaptureScreen 抓取屏幕并返回 CBitmap,需要使用 defer robotgo.FreeBitmap(bitmap) 释放
func ImgToCBitmap ← 0.110.0
| |
ImgToCBitmap trans image.Image to CBitmap
ImgToCBitmap 将 image.Image 转换为 CBitmap
func ToCBitmap
| |
ToCBitmap trans Bitmap to C.MMBitmapRef
ToCBitmap 将 Bitmap 转换为 C.MMBitmapRef
type CHex
| |
CHex define CHex as c rgb Hex type (C.MMRGBHex)
CHex 定义为 C.MMRGBHex 类型
func UintToHex
| |
UintToHex trans uint32 to robotgo.CHex
UintToHex 将 uint32 转换为 CHex
type Handle ← 0.110.3
| |
Handle define window Handle as C.MData type
Handle 定义为 C.MData 类型,表示窗口句柄
func GetActive
| |
GetActive get the active window
GetActive 获取当前激活窗口句柄
func GetHandById ← 0.110.3
| |
GetHandById get handle mdata by id
GetHandById 根据窗口 ID 获取 Handle
func GetHandByPid ← 0.110.3
| |
GetHandByPid get handle mdata by pid
GetHandByPid 根据 PID 获取 Handle
func GetHandPid ← DEPRECATED
| |
Deprecated: use the GetHandByPid(),
GetHandPid get handle mdata by pid
已弃用:请使用 GetHandByPid(),
GetHandPid 根据 PID 获取 Handle
type Map
| |
Map a map[string]interface{}
Map 定义为 map[string]interface{}
type Nps
| |
Nps process struct
Nps 表示进程信息的结构体
func Process
| |
Process get the all process struct
Process 获取所有进程信息列表
type Point ← 0.100.3
| |
Point is point struct
Point 表示坐标点的结构体
type Rect ← 0.100.3
| |
Rect is rect structure
Rect 表示矩形区域的结构体,包含 Point 和 Size
func GetDisplayRect ← 0.110.0
| |
GetDisplayRect gets the display rect
GetDisplayRect 获取第 i 个显示器的矩形区域
func GetScreenRect ← 0.100.3
| |
GetScreenRect get the screen rect (x, y, w, h)
GetScreenRect 获取屏幕矩形区域 (x, y, w, h)
type Size ← 0.100.3
type Size struct {
W, H int
}
Size is size structure
Size 表示尺寸的结构体,包含宽 W 和高 H