# 方法: ##### [GetVersion](#GetVersion) ## [键盘](#Keyboard) ##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md) ##### [SetKeyDelay](#SetKeyDelay) ##### [KeyTap](#KeyTap) ##### [KeyToggle](#KeyToggle) ##### [TypeStr](#TypeStr) ##### [TypeStrDelay](#TypeStrDelay) ##### [WriteAll](#WriteAll) ##### [ReadAll](#ReadAll) ## [鼠标](#Mouse) ##### [SetMouseDelay](#SetMouseDelay) ##### [MoveMouse](#MoveMouse) ##### [Move](#MoveMouse) (相当于 MoveMouse) ##### [MoveMouseSmooth](#MoveMouseSmooth) ##### [MoveSmooth](#MoveMouseSmooth) (相当与 MoveMouseSmooth) ##### [MouseClick](#MouseClick) ##### [Click](#MouseClick) (相当于 MouseClick) ##### [MoveClick](#MoveClick) ##### [MouseToggle](#MouseToggle) ##### [DragMouse](#DragMouse) ##### [Drag](#DragMouse) (相当于 DragMouse) ##### [GetMousePos](#GetMousePos) ##### [ScrollMouse](#ScrollMouse) ###

.GetVersion()

获取 robotgo 版本 ## [屏幕](#Screen) ##### [GetPixelColor](#GetPixelColor) ##### [GetScreenSize](#GetScreenSize) ##### [CaptureScreen](#CaptureScreen) ##### [GetXDisplayName(Linux)](#GetXDisplayName) ##### [SetXDisplayName(Linux)](#SetXDisplayName) ## [位图](#Bitmap) This is a work in progress. (工作正在进行中) ##### [FindBitmap](#FindBitmap) ##### [OpenBitmap](#OpenBitmap) ##### [SaveBitmap](#SaveBitmap) ##### [TostringBitmap](#TostringBitmap) ##### [GetPortion](#GetPortion) ##### [Convert](#Convert) #### [FreeBitmap](#FreeBitmap) #### [ReadBitmap](#ReadBitmap) #### [CopyBitpb](#CopyBitpb) #### [DeepCopyBit](#DeepCopyBit) ## [事件](#Event) ##### [AddEvent](#AddEvent) ##### [StopEvent](#StopEvent) ## [窗口](#Window) This is a work in progress. ##### [ShowAlert](#ShowAlert) ##### [CloseWindow](#CloseWindow) ##### [IsValid](#IsValid) ##### [SetActive](#SetActive) ##### [GetActive](#GetActive) ##### [SetHandle](#SetHandle) ##### [GetHandle](#GetHandle) ##### [GetTitle](#GetTitle) ##### [GetPID](#GetPID) ##### [Pids](#Pids) ##### [PidExists](#PidExists) ##### [Process](#Process) ##### [FindName](#FindName) ##### [FindNames](#FindNames) ##### [FindIds](#FindIds) #### [ActivePID](#ActivePID) ##

键盘

###

.SetKeyDelay(ms)

设置键盘延迟 (在键盘一个事件后), 单位 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. ###

.KeyTap(key, modifier)

模拟键盘按键 Press a single key. #### 参数: 键盘值 修饰值 (可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift. key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md). modifier (optional, string or array) - Accepts alt, command (win), control, and shift. #### 示例: ```Go robotgo.KeyTap("h", "command") robotgo.KeyTap("i", "alt", "command") arr := []string{"alt", "command"} robotgo.KeyTap("i", arr) ``` ###

.KeyToggle(key, down, modifier)

键盘切换, 按住或释放一个键位 Hold down or release a key. #### 参数: key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md). down - Accepts 'down' or 'up'. modifier (optional, string or array) - Accepts alt, command (mac), control, and shift. ### 返回值: 返回 KeyToggle 状态 ###

.TypeStr(string)

#### 参数: string - The string to send. ###

.TypeStrDelay(string, cpm)

#### 参数: string - The string to send. cpm - Characters per minute. ###

.WriteAll(text string)

#### 参数: text string #### 返回值: ###

.ReadAll()

#### 参数: #### 返回值: text, error ##

鼠标

###

.SetMouseDelay(ms)

设置鼠标延迟 (在一个鼠标事件后), 单位 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. ###

.MoveMouse(x, y)

移动鼠标 Moves mouse to x, y instantly, with the mouse button up. #### 参数: x, y #### 示例: ```Go // Move the mouse to 100, 100 on the screen. robotgo.MoveMouse(100, 100) ``` ###

.MoveMouseSmooth(x, y)

模拟鼠标向 X,Y 平滑移动(像人类一样),用鼠标按钮向上 Moves mouse to x, y human like, with the mouse button up. #### 参数: x, y lowspeed, highspeed #### 示例: ```Go robotgo.MoveMouseSmooth(100, 200) robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) ``` ###

.MouseClick(button, double)

鼠标点击 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. #### 示例: ```Go robotgo.MouseClick() robotgo.MouseClick("left", true) ``` ###

.MoveClick(x, y, button, double)

移动并点击鼠标 #### 参数: 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. #### 示例: ```Go robotgo.MoveClick(10, 20) robotgo.MoveClick(10, 20, "left", true) ``` ###

.MouseToggle(down, button)

鼠标切换 Toggles mouse button. #### 参数: down (optional) - Accepts down or up. Defaults to down. button (optional) - Accepts "left", "right", or "center". Defaults to left. #### 示例: ```Go robotgo.MouseToggle("down") robotgo.MouseToggle("down", "right") ``` ###

.DragMouse(x, y)

拖动鼠标 Moves mouse to x, y instantly, with the mouse button held down. #### 参数: x, y #### 示例: ```Go // 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") ``` ###

.GetMousePos()

获取鼠标的位置 Gets the mouse coordinates. #### 返回值: Returns an object with keys x and y. #### 示例: ```Go x, y := robotgo.GetMousePos() fmt.Println("pos:", x, y) ``` ###

.ScrollMouse(magnitude, direction)

滚动鼠标 Scrolls the mouse either up or down. #### 参数: 滚动位置的大小 滚动方向: up (向上滚动) down (向下滚动) magnitude - The amount to scroll. direction - Accepts down or up. #### 示例: ```Go robotgo.ScrollMouse(50, "up") robotgo.ScrollMouse(50, "down") ``` ##

屏幕

###

.GetPixelColor(x, y) 获取坐标为 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. ###

.GetScreenSize()

获取屏幕大小 Gets the screen width and height. #### 返回值: Returns an object with .width and .height. ###

.CaptureScreen

// 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. ###

.FindBitmap

查找 bitmap. #### 参数: bitmap; rect (可选参数): x, y, w, h #### Return: 查找到, 返回 bitmap 的 x 和y 坐标; 没有返回 nil ###

.OpenBitmap

打开 bitmap 图片. #### 参数: bitmap 图片路径, MMImageType (可选) #### 返回值: 返回一个 bitmap 对象 ###

.SaveBitmap

保存一个 bitmap 图片. #### 参数: bitmap 对象, 保存路径, imagetype (int) #### 返回值: 保存图片, 返回保存状态 ###

.TostringBitmap

将一个 bitmap 对象转换为字符串对象. #### 参数: bitmap 对象 #### Return: 返回一个 bitmap 字符串 ###

.GetPortion

bitmap from a portion #### 参数: bitmap, rect: x, y, w, h #### 返回值: Returns new bitmap object created from a portion of another ###

.Convert(openpath, savepath, MMImageType)

转换 bitmap 图片格式 #### 参数: openpath, savepath, MMImageType (可选) #### 示例: ```Go robotgo.Convert("test.png", "test.tif") ``` ###

.FreeBitmap(MMBitmapRef)

FreeBitmap free and dealloc bitmap #### 参数: MMBitmapRef #### 示例: ```Go robotgo.FreeBitmap(bitmap) ``` ###

.ReadBitmap(MMBitmapRef)

ReadBitmap returns false and sets error if |bitmap| is NULL #### 参数: MMBitmapRef #### 返回值: bool #### 示例: ```Go robotgo.ReadBitmap(bitmap) ``` ###

.CopyBitpb(MMBitmapRef)

CopyBitpb copy bitmap to pasteboard #### 参数: MMBitmapRef #### 返回值: bool #### 示例: ```Go robotgo.CopyBitpb(bitmap) ``` ###

.DeepCopyBit(MMBitmapRef)

DeepCopyBit deep copy bitmap #### 参数: MMBitmapRef #### 返回值: MMBitmapRef #### 示例: ```Go robotgo.DeepCopyBit(bitmap) ``` ##

事件

###

.AddEvent(string)

监听全局事件 #### 参数: string (鼠标参数: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight) #### 返回值: 监听成功返回 0 #### 示例: ```Go 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") } } ``` ###

.StopEvent()

停止事件监听 ##

窗口

###

.ShowAlert(title, msg, defaultButton, cancelButton string)

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. ###

.CloseWindow()

关闭窗口 #### 参数: 无 #### 返回值: 无 ###

.IsValid()

Valid the Window #### 参数: 无 #### 返回值: 如果窗口 selected 返回 true ###

.SetActive()

设为当前窗口 #### 参数: hwnd #### 返回值: void ###

.GetActive()

获取当前窗口 #### 参数: 无 #### 返回值: Returns hwnd ###

.SetHandle()

Set the Window Handle #### 参数: int #### 返回值: bool ###

.GetHandle()

获取窗口 Handle #### 参数: 无 #### 返回值: Returns hwnd ###

.GetTitle()

获取窗口标题 #### 参数: #### 返回值: 返回窗口标题 ###

.GetPID()

获取进程 id #### 参数: 无 #### 返回值: 返回进程 id ###

.Pids()

获取所有进程 id #### 参数: 无 #### 返回值: 返回进程 id ###

.PidExists()

判断进程 id 是否存在 #### 参数: pid #### 返回值: 返回 bool ###

.Process()

Process get the all process struct #### 参数: 无 #### 返回值: Returns []Nps, error ###

.FindName()

FindName find the process name by the process id #### 参数: pid #### 返回值: Returns string, error ###

.FindNames()

FindNames find the all process name #### Arguments: none #### Return: Returns []string, error ###

.FindIds()

FindIds find the process id by the process name #### Arguments: name string #### Return: Returns []int32, error ###

.ActivePID()

ActivePID window active by PID #### Arguments: pid int32 #### Return: none