Fix doc.md

This commit is contained in:
vCaesar 2017-03-15 16:41:45 +08:00
parent 3a04f0ca44
commit b5ad8b3e4c

View File

@ -1,242 +1,242 @@
#方法: # 方法:
#####[GetVersion](#GetVersion) ##### [GetVersion](#GetVersion)
##[键盘](#Keyboard) ## [键盘](#Keyboard)
#####[Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md) ##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)
#####[SetKeyboardDelay](#SetKeyDelay)(相当于SetKeyDelay,废弃API) ##### [SetKeyboardDelay](#SetKeyDelay)(相当于SetKeyDelay,废弃API)
#####[SetKeyDelay](#SetKeyDelay) ##### [SetKeyDelay](#SetKeyDelay)
#####[KeyTap](#KeyTap) ##### [KeyTap](#KeyTap)
#####[KeyToggle](#KeyToggle) ##### [KeyToggle](#KeyToggle)
#####[TypeString](#TypeString) ##### [TypeString](#TypeString)
#####[TypeStringDelayed](#TypeStrDelay)(相当于TypeStrDelay,废弃API) ##### [TypeStringDelayed](#TypeStrDelay)(相当于TypeStrDelay,废弃API)
#####[TypeStrDelay](#TypeStrDelay) ##### [TypeStrDelay](#TypeStrDelay)
##[鼠标](#Mouse) ## [鼠标](#Mouse)
#####[SetMouseDelay](#SetMouseDelay) ##### [SetMouseDelay](#SetMouseDelay)
#####[MoveMouse](#MoveMouse) ##### [MoveMouse](#MoveMouse)
#####[Move](#MoveMouse)(相当于MoveMouse) ##### [Move](#MoveMouse)(相当于MoveMouse)
#####[MoveMouseSmooth](#MoveMouseSmooth) ##### [MoveMouseSmooth](#MoveMouseSmooth)
#####[MoveSmooth](#MoveMouseSmooth)(相当与MoveMouseSmooth) ##### [MoveSmooth](#MoveMouseSmooth)(相当与MoveMouseSmooth)
#####[MouseClick](#MouseClick) ##### [MouseClick](#MouseClick)
#####[Click](#MouseClick)(相当于MouseClick) ##### [Click](#MouseClick)(相当于MouseClick)
#####[MoveClick](#MoveClick) ##### [MoveClick](#MoveClick)
#####[MouseToggle](#MouseToggle) ##### [MouseToggle](#MouseToggle)
#####[DragMouse](#DragMouse) ##### [DragMouse](#DragMouse)
#####[Drag](#DragMouse)(相当于DragMouse) ##### [Drag](#DragMouse)(相当于DragMouse)
#####[GetMousePos](#GetMousePos) ##### [GetMousePos](#GetMousePos)
#####[ScrollMouse](#ScrollMouse) ##### [ScrollMouse](#ScrollMouse)
###<h3 id="GetVersion">.GetVersion()</h3> ### <h3 id="GetVersion">.GetVersion()</h3>
获取robotgo版本 获取robotgo版本
##[屏幕](#Screen) ## [屏幕](#Screen)
#####[GetPixelColor](#GetPixelColor) ##### [GetPixelColor](#GetPixelColor)
#####[GetScreenSize](#GetScreenSize) ##### [GetScreenSize](#GetScreenSize)
#####[CaptureScreen](#CaptureScreen) ##### [CaptureScreen](#CaptureScreen)
#####[GetXDisplayName(Linux)](#GetXDisplayName) ##### [GetXDisplayName(Linux)](#GetXDisplayName)
#####[SetXDisplayName(Linux)](#SetXDisplayName) ##### [SetXDisplayName(Linux)](#SetXDisplayName)
##[位图](#Bitmap) ## [位图](#Bitmap)
This is a work in progress.(工作正在进行中) This is a work in progress.(工作正在进行中)
#####[FindBitmap](#FindBitmap) ##### [FindBitmap](#FindBitmap)
#####[OpenBitmap](#OpenBitmap) ##### [OpenBitmap](#OpenBitmap)
#####[SaveBitmap](#SaveBitmap) ##### [SaveBitmap](#SaveBitmap)
#####[TostringBitmap](#TostringBitmap) ##### [TostringBitmap](#TostringBitmap)
#####[GetPortion](#GetPortion) ##### [GetPortion](#GetPortion)
#####[Convert](#Convert) ##### [Convert](#Convert)
##[事件](#Event) ## [事件](#Event)
#####[LEvent](#AddEvent)(相当于AddEvent,废弃API) ##### [LEvent](#AddEvent)(相当于AddEvent,废弃API)
#####[AddEvent](#AddEvent) ##### [AddEvent](#AddEvent)
#####[StopEvent](#StopEvent) ##### [StopEvent](#StopEvent)
##[窗口](#Window) ## [窗口](#Window)
This is a work in progress. This is a work in progress.
#####[ShowAlert](#ShowAlert) ##### [ShowAlert](#ShowAlert)
#####[CloseWindow](#CloseWindow) ##### [CloseWindow](#CloseWindow)
#####[IsValid](#IsValid) ##### [IsValid](#IsValid)
#####[SetActive](#SetActive) ##### [SetActive](#SetActive)
#####[GetActive](#GetActive) ##### [GetActive](#GetActive)
#####[SetHandle](#SetHandle) ##### [SetHandle](#SetHandle)
#####[GetHandle](#GetHandle) ##### [GetHandle](#GetHandle)
#####[GetBHandle](#GetHandle) ##### [GetBHandle](#GetHandle)
#####[GetTitle](#GetTitle) ##### [GetTitle](#GetTitle)
#####[GetPID](#GetPID) ##### [GetPID](#GetPID)
##<h2 id="Keyboard">键盘</h2> ## <h2 id="Keyboard">键盘</h2>
###<h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3> ### <h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3>
设置键盘延迟(在键盘一个事件后),单位ms,默认值10ms 设置键盘延迟(在键盘一个事件后),单位ms,默认值10ms
Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default. Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.
####参数: #### 参数:
延迟时间,单位ms 延迟时间,单位ms
ms - Time to sleep in milliseconds. ms - Time to sleep in milliseconds.
###<h3 id="KeyTap">.KeyTap(key, modifier)</h3> ### <h3 id="KeyTap">.KeyTap(key, modifier)</h3>
模拟键盘按键 模拟键盘按键
Press a single key. Press a single key.
####参数: #### 参数:
键盘值 键盘值
修饰值(可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift. 修饰值(可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift.
key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md). 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. modifier (optional, string or array) - Accepts alt, command (win), control, and shift.
####示例: #### 示例:
```Go ```Go
robotgo.KeyTap("h", "command") robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command") robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"} arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr) robotgo.KeyTap("i", arr)
``` ```
###<h3 id="KeyToggle">.KeyToggle(key, down, modifier)</h3> ### <h3 id="KeyToggle">.KeyToggle(key, down, modifier)</h3>
键盘切换,按住或释放一个键位 键盘切换,按住或释放一个键位
Hold down or release a key. Hold down or release a key.
####参数: #### 参数:
key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md). key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).
down - Accepts 'down' or 'up'. down - Accepts 'down' or 'up'.
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift. modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.
###返回值: ### 返回值:
返回KeyToggle状态 返回KeyToggle状态
###<h3 id="TypeString">.TypeString(string)</h3> ### <h3 id="TypeString">.TypeString(string)</h3>
####参数: #### 参数:
string - The string to send. string - The string to send.
###<h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3> ### <h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3>
####参数: #### 参数:
string - The string to send. string - The string to send.
cpm - Characters per minute. cpm - Characters per minute.
##<h2 id="Mouse">鼠标</h2> ## <h2 id="Mouse">鼠标</h2>
###<h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3> ### <h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3>
设置鼠标延迟(在一个鼠标事件后),单位ms,默认值10ms 设置鼠标延迟(在一个鼠标事件后),单位ms,默认值10ms
Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default. Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.
####参数: #### 参数:
ms - Time to sleep in milliseconds. ms - Time to sleep in milliseconds.
###<h3 id="MoveMouse">.MoveMouse(x, y)</h3> ### <h3 id="MoveMouse">.MoveMouse(x, y)</h3>
移动鼠标 移动鼠标
Moves mouse to x, y instantly, with the mouse button up. Moves mouse to x, y instantly, with the mouse button up.
####参数: #### 参数:
x,y x,y
####示例: #### 示例:
```Go ```Go
//Move the mouse to 100, 100 on the screen. // Move the mouse to 100, 100 on the screen.
robotgo.MoveMouse(100, 100) robotgo.MoveMouse(100, 100)
``` ```
###<h3 id="MoveMouseSmooth">.MoveMouseSmooth(x, y)</h3> ### <h3 id="MoveMouseSmooth">.MoveMouseSmooth(x, y)</h3>
模拟鼠标向XY平滑移动(像人类一样),用鼠标按钮向上 模拟鼠标向XY平滑移动(像人类一样),用鼠标按钮向上
Moves mouse to x, y human like, with the mouse button up. Moves mouse to x, y human like, with the mouse button up.
####参数: #### 参数:
x,y x,y
lowspeed,highspeed lowspeed,highspeed
####示例: #### 示例:
```Go ```Go
robotgo.MoveMouseSmooth(100, 200) robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
``` ```
###<h3 id="MouseClick">.MouseClick(button, double)</h3> ### <h3 id="MouseClick">.MouseClick(button, double)</h3>
鼠标点击 鼠标点击
Clicks the mouse. Clicks the mouse.
####参数: #### 参数:
button (optional) - Accepts left, right, or center. Defaults to left. button (optional) - Accepts left, right, or center. Defaults to left.
double (optional) - Set to true to perform a double click. Defaults to false. double (optional) - Set to true to perform a double click. Defaults to false.
####示例: #### 示例:
```Go ```Go
robogo.MouseClick() robogo.MouseClick()
robogo.MouseClick("left", true) robogo.MouseClick("left", true)
``` ```
###<h3 id="MoveClick">.MoveClick(x, y, button, double)</h3> ### <h3 id="MoveClick">.MoveClick(x, y, button, double)</h3>
移动并点击鼠标 移动并点击鼠标
####参数: #### 参数:
x, x,
y, y,
button (optional) - Accepts "left", "right", or "center". Defaults to left. button (optional) - Accepts "left", "right", or "center". Defaults to left.
double (optional) - Set to true to perform a double click. Defaults to false. double (optional) - Set to true to perform a double click. Defaults to false.
####示例: #### 示例:
```Go ```Go
robogo.MoveClick(10, 20) robogo.MoveClick(10, 20)
robogo.MoveClick(10, 20, "left", true) robogo.MoveClick(10, 20, "left", true)
``` ```
###<h3 id="MouseToggle">.MouseToggle(down, button)</h3> ### <h3 id="MouseToggle">.MouseToggle(down, button)</h3>
鼠标切换 鼠标切换
Toggles mouse button. Toggles mouse button.
####参数: #### 参数:
down (optional) - Accepts down or up. Defaults to down. down (optional) - Accepts down or up. Defaults to down.
button (optional) - Accepts "left", "right", or "center". Defaults to left. button (optional) - Accepts "left", "right", or "center". Defaults to left.
####示例: #### 示例:
```Go ```Go
robotgo.MouseToggle("down") robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right") robotgo.MouseToggle("down", "right")
``` ```
###<h3 id="DragMouse">.DragMouse(x, y)</h3> ### <h3 id="DragMouse">.DragMouse(x, y)</h3>
拖动鼠标 拖动鼠标
Moves mouse to x, y instantly, with the mouse button held down. Moves mouse to x, y instantly, with the mouse button held down.
####参数: #### 参数:
x,y x,y
####示例: #### 示例:
```Go ```Go
// Mouse down at 0, 0 and then drag to 100, 100 and release. // Mouse down at 0, 0 and then drag to 100, 100 and release.
@ -246,35 +246,35 @@ robotgo.DragMouse(100, 100)
robotgo.MouseToggle("up") robotgo.MouseToggle("up")
``` ```
###<h3 id="GetMousePos">.GetMousePos()</h3> ### <h3 id="GetMousePos">.GetMousePos()</h3>
获取鼠标的位置 获取鼠标的位置
Gets the mouse coordinates. Gets the mouse coordinates.
####返回值: #### 返回值:
Returns an object with keys x and y. Returns an object with keys x and y.
####示例: #### 示例:
```Go ```Go
x,y := robotgo.GetMousePos() x,y := robotgo.GetMousePos()
fmt.Println("pos:", x, y) fmt.Println("pos:", x, y)
``` ```
###<h3 id="ScrollMouse">.ScrollMouse(magnitude, direction)</h3> ### <h3 id="ScrollMouse">.ScrollMouse(magnitude, direction)</h3>
滚动鼠标 滚动鼠标
Scrolls the mouse either up or down. Scrolls the mouse either up or down.
####参数: #### 参数:
滚动位置的大小 滚动位置的大小
滚动方向:up(向上滚动) down(向下滚动) 滚动方向:up(向上滚动) down(向下滚动)
magnitude - The amount to scroll. magnitude - The amount to scroll.
direction - Accepts down or up. direction - Accepts down or up.
####示例: #### 示例:
```Go ```Go
robotgo.ScrollMouse(50, "up") robotgo.ScrollMouse(50, "up")
@ -283,30 +283,30 @@ robotgo.ScrollMouse(50, "down")
``` ```
##<h2 id="Screen">屏幕</h2> ## <h2 id="Screen">屏幕</h2>
###<h3 id="GetPixelColor">.GetPixelColor(x, y) ### <h3 id="GetPixelColor">.GetPixelColor(x, y)
获取坐标为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. 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 x,y
####返回值: #### 返回值:
Returns the hex color code of the pixel at x, y. Returns the hex color code of the pixel at x, y.
###<h3 id="GetScreenSize">.GetScreenSize()</h3> ### <h3 id="GetScreenSize">.GetScreenSize()</h3>
获取屏幕大小 获取屏幕大小
Gets the screen width and height. Gets the screen width and height.
####返回值: #### 返回值:
Returns an object with .width and .height. Returns an object with .width and .height.
###<h3 id="CaptureScreen">.CaptureScreen</h3> ### <h3 id="CaptureScreen">.CaptureScreen</h3>
// CaptureScreen // CaptureScreen
获取部分或者全部屏幕 获取部分或者全部屏幕
Gets part or all of the screen. Gets part or all of the screen.
@ -314,7 +314,7 @@ robotgo.ScrollMouse(50, "down")
BCaptureScreen Returns a go struct BCaptureScreen Returns a go struct
Capture_Screen(Drop support) Capture_Screen(Drop support)
####参数: #### 参数:
x (optional) x (optional)
y (optional) y (optional)
@ -322,113 +322,113 @@ robotgo.ScrollMouse(50, "down")
width (optional) width (optional)
If no arguments are provided, screen.capture will get the full screen. If no arguments are provided, screen.capture will get the full screen.
####返回值: #### 返回值:
返回一个bitmap object. 返回一个bitmap object.
##<h2 id="Bitmap">位图</h2> ## <h2 id="Bitmap">位图</h2>
This is a work in progress. This is a work in progress.
###<h3 id="FindBitmap">.FindBitmap</h3> ### <h3 id="FindBitmap">.FindBitmap</h3>
查找bitmap. 查找bitmap.
####参数: #### 参数:
bitmap; bitmap;
rect(可选参数): x, y, w, h rect(可选参数): x, y, w, h
####Return: #### Return:
查找到,返回bitmap的x和y坐标;没有返回nil 查找到,返回bitmap的x和y坐标;没有返回nil
###<h3 id="OpenBitmap">.OpenBitmap</h3> ### <h3 id="OpenBitmap">.OpenBitmap</h3>
打开bitmap图片. 打开bitmap图片.
####参数: #### 参数:
bitmap图片路径, bitmap图片路径,
MMImageType(可选) MMImageType(可选)
####返回值: #### 返回值:
返回一个bitmap对象 返回一个bitmap对象
###<h3 id="SaveBitmap">.SaveBitmap</h3> ### <h3 id="SaveBitmap">.SaveBitmap</h3>
保存一个bitmap图片. 保存一个bitmap图片.
####参数: #### 参数:
bitmap对象, bitmap对象,
保存路径, 保存路径,
imagetype(int) imagetype(int)
####返回值: #### 返回值:
保存图片,返回保存状态 保存图片,返回保存状态
###<h3 id="TostringBitmap">.TostringBitmap</h3> ### <h3 id="TostringBitmap">.TostringBitmap</h3>
将一个bitmap对象转换为字符串对象. 将一个bitmap对象转换为字符串对象.
####参数: #### 参数:
bitmap对象 bitmap对象
####Return: #### Return:
返回一个bitmap字符串 返回一个bitmap字符串
###<h3 id="GetPortion">.GetPortion</h3> ### <h3 id="GetPortion">.GetPortion</h3>
bitmap from a portion bitmap from a portion
####参数: #### 参数:
bitmap, bitmap,
rect: x, y, w, h rect: x, y, w, h
####返回值: #### 返回值:
Returns new bitmap object created from a portion of another Returns new bitmap object created from a portion of another
###<h3 id="Convert">.Convert(openpath, savepath,MMImageType)</h3> ### <h3 id="Convert">.Convert(openpath, savepath,MMImageType)</h3>
转换bitmap图片格式 转换bitmap图片格式
####参数: #### 参数:
openpath, openpath,
savepath, savepath,
MMImageType(可选) MMImageType(可选)
####示例: #### 示例:
```Go ```Go
robotgo.Convert("test.png", "test.tif") robotgo.Convert("test.png", "test.tif")
``` ```
##<h2 id="Event">事件</h2> ##<h2 id="Event">事件</h2>
###<h3 id="AddEvent">.AddEvent(string)</h3> ### <h3 id="AddEvent">.AddEvent(string)</h3>
监听全局事件 监听全局事件
####参数: #### 参数:
string string
(鼠标参数:mleft mright wheelDown wheelUp wheelLeft wheelRight) (鼠标参数:mleft mright wheelDown wheelUp wheelLeft wheelRight)
####返回值: #### 返回值:
监听成功返回0 监听成功返回0
####示例: #### 示例:
```Go ```Go
package main package main
@ -452,16 +452,16 @@ func main() {
} }
``` ```
###<h3 id="StopEvent">.StopEvent()</h3> ### <h3 id="StopEvent">.StopEvent()</h3>
停止事件监听 停止事件监听
##<h2 id="Window">窗口</h2> ## <h2 id="Window">窗口</h2>
###<h3 id="ShowAlert">.ShowAlert(title, msg,defaultButton,cancelButton string)</h3> ### <h3 id="ShowAlert">.ShowAlert(title, msg,defaultButton,cancelButton string)</h3>
Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed
####参数: #### 参数:
title(string), title(string),
msg(string), msg(string),
@ -469,88 +469,88 @@ func main() {
cancelButton(optional string) cancelButton(optional string)
####返回值: #### 返回值:
Returns 0(True) if the default button was pressed, or 1(False) if cancelled. Returns 0(True) if the default button was pressed, or 1(False) if cancelled.
###<h3 id="CloseWindow">.CloseWindow()</h3> ### <h3 id="CloseWindow">.CloseWindow()</h3>
关闭窗口 关闭窗口
####参数: #### 参数:
####返回值: #### 返回值:
###<h3 id="IsValid">.IsValid()</h3> ### <h3 id="IsValid">.IsValid()</h3>
Valid the Window Valid the Window
####参数: #### 参数:
####返回值: #### 返回值:
如果窗口selected返回true 如果窗口selected返回true
###<h3 id="SetActive">.SetActive()</h3> ### <h3 id="SetActive">.SetActive()</h3>
设为当前窗口 设为当前窗口
####参数: #### 参数:
hwnd hwnd
####返回值: #### 返回值:
void void
###<h3 id="GetActive">.GetActive()</h3> ### <h3 id="GetActive">.GetActive()</h3>
获取当前窗口 获取当前窗口
####参数: #### 参数:
####返回值: #### 返回值:
Returns hwnd Returns hwnd
###<h3 id="SetHandle">.SetHandle()</h3> ### <h3 id="SetHandle">.SetHandle()</h3>
Set the Window Handle Set the Window Handle
####参数: #### 参数:
int int
####返回值: #### 返回值:
bool bool
###<h3 id="GetHandle">.GetHandle()</h3> ### <h3 id="GetHandle">.GetHandle()</h3>
获取窗口 Handle 获取窗口 Handle
####参数: #### 参数:
####返回值: #### 返回值:
Returns hwnd Returns hwnd
###<h3 id="GetTitle">.GetTitle()</h3> ### <h3 id="GetTitle">.GetTitle()</h3>
获取窗口标题 获取窗口标题
####参数: #### 参数:
####返回值: #### 返回值:
返回窗口标题 返回窗口标题
###<h3 id="GetPID">.GetPID()</h3> ### <h3 id="GetPID">.GetPID()</h3>
获取进程id 获取进程id
####参数: #### 参数:
####返回值: #### 返回值:
返回进程id 返回进程id