robotgo/docs/doc_zh.md

730 lines
13 KiB
Markdown
Raw Permalink Normal View History

2017-03-15 08:41:45 +00:00
# 方法:
##### [GetVersion](#GetVersion)
## [键盘](#Keyboard)
##### [Keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md)
2017-04-03 13:37:22 +00:00
##### [SetKeyboardDelay](#SetKeyDelay) (相当于 SetKeyDelay, 废弃 API)
2017-03-15 08:41:45 +00:00
##### [SetKeyDelay](#SetKeyDelay)
##### [KeyTap](#KeyTap)
##### [KeyToggle](#KeyToggle)
##### [TypeString](#TypeString)
2017-04-03 13:37:22 +00:00
##### [TypeStringDelayed](#TypeStrDelay) (相当于 TypeStrDelay, 废弃 API)
2017-03-15 08:41:45 +00:00
##### [TypeStrDelay](#TypeStrDelay)
##### [TypeStr](#TypeStr)
##### [WriteAll](#WriteAll)
##### [ReadAll](#ReadAll)
2017-03-15 08:41:45 +00:00
## [鼠标](#Mouse)
##### [SetMouseDelay](#SetMouseDelay)
##### [MoveMouse](#MoveMouse)
2017-04-03 13:37:22 +00:00
##### [Move](#MoveMouse) (相当于 MoveMouse)
2017-03-15 08:41:45 +00:00
##### [MoveMouseSmooth](#MoveMouseSmooth)
2017-04-03 13:37:22 +00:00
##### [MoveSmooth](#MoveMouseSmooth) (相当与 MoveMouseSmooth)
2017-03-15 08:41:45 +00:00
##### [MouseClick](#MouseClick)
2017-04-03 13:37:22 +00:00
##### [Click](#MouseClick) (相当于 MouseClick)
2017-03-15 08:41:45 +00:00
##### [MoveClick](#MoveClick)
##### [MouseToggle](#MouseToggle)
##### [DragMouse](#DragMouse)
2017-04-03 13:37:22 +00:00
##### [Drag](#DragMouse) (相当于 DragMouse)
2017-03-15 08:41:45 +00:00
##### [GetMousePos](#GetMousePos)
##### [ScrollMouse](#ScrollMouse)
### <h3 id="GetVersion">.GetVersion()</h3>
2017-03-24 15:14:55 +00:00
获取 robotgo 版本
2017-01-03 10:39:22 +00:00
2017-03-15 08:41:45 +00:00
## [屏幕](#Screen)
2016-10-24 13:52:25 +00:00
2017-03-15 08:41:45 +00:00
##### [GetPixelColor](#GetPixelColor)
##### [GetScreenSize](#GetScreenSize)
##### [CaptureScreen](#CaptureScreen)
##### [GetXDisplayName(Linux)](#GetXDisplayName)
##### [SetXDisplayName(Linux)](#SetXDisplayName)
2016-10-24 13:52:25 +00:00
2017-03-15 08:41:45 +00:00
## [位图](#Bitmap)
2017-03-24 15:14:55 +00:00
This is a work in progress. (工作正在进行中)
2016-10-09 04:49:14 +00:00
2017-03-15 08:41:45 +00:00
##### [FindBitmap](#FindBitmap)
##### [OpenBitmap](#OpenBitmap)
##### [SaveBitmap](#SaveBitmap)
##### [TostringBitmap](#TostringBitmap)
##### [GetPortion](#GetPortion)
##### [Convert](#Convert)
2017-06-03 14:14:36 +00:00
#### [FreeBitmap](#FreeBitmap)
2017-06-07 12:44:52 +00:00
#### [ReadBitmap](#ReadBitmap)
#### [CopyBitpb](#CopyBitpb)
2017-06-30 14:54:07 +00:00
#### [DeepCopyBit](#DeepCopyBit)
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
## [事件](#Event)
2016-10-30 13:35:01 +00:00
2017-04-03 13:37:22 +00:00
##### [LEvent](#AddEvent) (相当于 AddEvent, 废弃 API)
2017-03-15 08:41:45 +00:00
##### [AddEvent](#AddEvent)
##### [StopEvent](#StopEvent)
2016-10-30 13:35:01 +00:00
2017-03-15 08:41:45 +00:00
## [窗口](#Window)
2016-11-07 08:46:22 +00:00
This is a work in progress.
2017-03-15 08:41:45 +00:00
##### [ShowAlert](#ShowAlert)
##### [CloseWindow](#CloseWindow)
##### [IsValid](#IsValid)
##### [SetActive](#SetActive)
##### [GetActive](#GetActive)
##### [SetHandle](#SetHandle)
##### [GetHandle](#GetHandle)
##### [GetBHandle](#GetHandle)
##### [GetTitle](#GetTitle)
##### [GetPID](#GetPID)
2017-07-25 15:16:24 +00:00
##### [Pids](#Pids)
##### [PidExists](#PidExists)
2017-08-03 14:43:21 +00:00
##### [Process](#Process)
##### [FindName](#FindName)
2017-08-21 14:51:42 +00:00
##### [FindNames](#FindNames)
##### [FindIds](#FindIds)
2017-10-03 12:17:35 +00:00
#### [ActivePID](#ActivePID)
2016-11-07 08:46:22 +00:00
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
## <h2 id="Keyboard">键盘</h2>
2017-02-24 08:19:27 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3>
2017-03-24 15:14:55 +00:00
设置键盘延迟 (在键盘一个事件后), 单位 ms, 默认值 10ms
2016-10-09 05:57:33 +00:00
Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.
2017-03-15 08:41:45 +00:00
#### 参数:
2017-03-24 15:14:55 +00:00
延迟时间,单位 ms
2016-10-09 05:57:33 +00:00
ms - Time to sleep in milliseconds.
2017-03-15 08:41:45 +00:00
### <h3 id="KeyTap">.KeyTap(key, modifier)</h3>
2016-10-09 05:57:33 +00:00
模拟键盘按键
Press a single key.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
键盘值
2017-03-24 15:14:55 +00:00
修饰值 (可选类型, 字符串或者数组) - 可选值: alt, command (win), control, and shift.
2016-10-09 05:57:33 +00:00
2017-02-24 18:40:10 +00:00
key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).
2017-02-24 17:34:13 +00:00
modifier (optional, string or array) - Accepts alt, command (win), control, and shift.
2017-03-15 08:41:45 +00:00
#### 示例:
2016-11-14 10:20:43 +00:00
```Go
2017-03-15 08:41:45 +00:00
robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
2016-11-14 10:20:43 +00:00
```
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="KeyToggle">.KeyToggle(key, down, modifier)</h3>
2017-03-24 15:14:55 +00:00
键盘切换, 按住或释放一个键位
2016-10-09 05:57:33 +00:00
Hold down or release a key.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2017-02-24 18:40:10 +00:00
key - See [keys](https://github.com/go-vgo/robotgo/blob/master/docs/keys.md).
down - Accepts 'down' or 'up'.
2017-02-24 17:34:13 +00:00
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.
2017-03-15 08:41:45 +00:00
### 返回值:
2016-12-30 09:13:21 +00:00
2017-03-24 15:14:55 +00:00
返回 KeyToggle 状态
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="TypeString">.TypeString(string)</h3>
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
string - The string to send.
2017-03-15 08:41:45 +00:00
### <h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3>
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
string - The string to send.
cpm - Characters per minute.
### <h3 id="TypeStr">.TypeStr(string)</h3>
2016-10-09 05:57:33 +00:00
#### 参数:
string - The string to send.
### <h3 id="WriteAll">.WriteAll(text string)</h3>
#### 参数:
text string
#### 返回值:
### <h3 id="ReadAll">.ReadAll()</h3>
#### 参数:
#### 返回值:
text,
error
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
## <h2 id="Mouse">鼠标</h2>
### <h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3>
2017-04-30 06:06:30 +00:00
设置鼠标延迟 (在一个鼠标事件后), 单位 ms, 默认值 10 ms
2016-10-09 05:57:33 +00:00
Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
ms - Time to sleep in milliseconds.
2017-03-15 08:41:45 +00:00
### <h3 id="MoveMouse">.MoveMouse(x, y)</h3>
2016-10-09 05:57:33 +00:00
移动鼠标
Moves mouse to x, y instantly, with the mouse button up.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
x, y
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2017-03-15 08:41:45 +00:00
// Move the mouse to 100, 100 on the screen.
2016-10-23 11:51:10 +00:00
robotgo.MoveMouse(100, 100)
2016-10-09 05:57:33 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="MoveMouseSmooth">.MoveMouseSmooth(x, y)</h3>
2017-03-24 15:14:55 +00:00
模拟鼠标向 XY 平滑移动(像人类一样),用鼠标按钮向上
2016-10-09 05:57:33 +00:00
Moves mouse to x, y human like, with the mouse button up.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
x, y
lowspeed, highspeed
2016-11-12 14:15:30 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-11-12 14:15:30 +00:00
```Go
2017-04-29 14:20:48 +00:00
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
2016-11-12 14:15:30 +00:00
```
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="MouseClick">.MouseClick(button, double)</h3>
2016-10-09 05:57:33 +00:00
鼠标点击
Clicks the mouse.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2016-11-12 13:24:19 +00:00
button (optional) - Accepts left, right, or center. Defaults to left.
2016-10-09 05:57:33 +00:00
double (optional) - Set to true to perform a double click. Defaults to false.
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2017-04-29 14:20:48 +00:00
robogo.MouseClick()
robogo.MouseClick("left", true)
2017-01-03 10:39:22 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="MoveClick">.MoveClick(x, y, button, double)</h3>
2017-01-03 10:39:22 +00:00
移动并点击鼠标
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-03 10:39:22 +00:00
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.
2017-03-15 08:41:45 +00:00
#### 示例:
2017-01-03 10:39:22 +00:00
```Go
2017-03-15 08:41:45 +00:00
robogo.MoveClick(10, 20)
robogo.MoveClick(10, 20, "left", true)
2016-10-09 05:57:33 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="MouseToggle">.MouseToggle(down, button)</h3>
2016-10-09 05:57:33 +00:00
鼠标切换
Toggles mouse button.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
down (optional) - Accepts down or up. Defaults to down.
2016-11-12 13:24:19 +00:00
button (optional) - Accepts "left", "right", or "center". Defaults to left.
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2016-10-23 11:51:10 +00:00
robotgo.MouseToggle("down")
2016-11-12 13:24:19 +00:00
robotgo.MouseToggle("down", "right")
2016-10-09 05:57:33 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="DragMouse">.DragMouse(x, y)</h3>
2016-10-09 05:57:33 +00:00
拖动鼠标
Moves mouse to x, y instantly, with the mouse button held down.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
x, y
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2017-03-04 16:15:14 +00:00
// Mouse down at 0, 0 and then drag to 100, 100 and release.
2016-10-23 11:51:10 +00:00
robotgo.MoveMouse(0, 0)
robotgo.MouseToggle("down")
robotgo.DragMouse(100, 100)
robotgo.MouseToggle("up")
2016-10-09 05:57:33 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="GetMousePos">.GetMousePos()</h3>
2016-10-14 05:30:47 +00:00
获取鼠标的位置
2016-10-09 05:57:33 +00:00
Gets the mouse coordinates.
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-09 05:57:33 +00:00
Returns an object with keys x and y.
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2017-03-24 15:14:55 +00:00
x, y := robotgo.GetMousePos()
2016-10-09 05:57:33 +00:00
fmt.Println("pos:", x, y)
```
2017-03-15 08:41:45 +00:00
### <h3 id="ScrollMouse">.ScrollMouse(magnitude, direction)</h3>
2016-10-09 05:57:33 +00:00
滚动鼠标
Scrolls the mouse either up or down.
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
滚动位置的大小
2017-03-24 15:14:55 +00:00
滚动方向: up (向上滚动) down (向下滚动)
2016-10-09 05:57:33 +00:00
magnitude - The amount to scroll.
direction - Accepts down or up.
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-09 05:57:33 +00:00
```Go
2016-10-23 11:51:10 +00:00
robotgo.ScrollMouse(50, "up")
2016-10-09 05:57:33 +00:00
2016-10-23 11:51:10 +00:00
robotgo.ScrollMouse(50, "down")
2016-10-09 05:57:33 +00:00
```
2017-03-15 08:41:45 +00:00
## <h2 id="Screen">屏幕</h2>
### <h3 id="GetPixelColor">.GetPixelColor(x, y)
2017-03-24 15:14:55 +00:00
获取坐标为 x, y 位置处的颜色
2016-10-09 05:57:33 +00:00
2017-04-29 14:08:27 +00:00
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.
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
x, y
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-09 05:57:33 +00:00
Returns the hex color code of the pixel at x, y.
2017-03-15 08:41:45 +00:00
### <h3 id="GetScreenSize">.GetScreenSize()</h3>
2016-10-09 05:57:33 +00:00
获取屏幕大小
Gets the screen width and height.
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-09 05:57:33 +00:00
Returns an object with .width and .height.
2017-03-15 08:41:45 +00:00
### <h3 id="CaptureScreen">.CaptureScreen</h3>
2017-03-04 16:15:14 +00:00
// CaptureScreen
2016-10-09 05:57:33 +00:00
获取部分或者全部屏幕
Gets part or all of the screen.
2017-11-09 14:47:53 +00:00
GoCaptureScreen Returns a go struct
2017-04-29 14:20:48 +00:00
Capture_Screen (废弃)
2016-11-12 14:45:42 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-09 05:57:33 +00:00
x (optional)
y (optional)
height (optional)
width (optional)
2017-04-30 06:06:30 +00:00
If no arguments are provided, capturescreen(screencapture) will get the full screen.
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
返回一个 bitmap object.
2016-10-09 05:57:33 +00:00
2017-03-15 08:41:45 +00:00
## <h2 id="Bitmap">位图</h2>
2016-10-09 05:57:33 +00:00
This is a work in progress.
2017-03-15 08:41:45 +00:00
### <h3 id="FindBitmap">.FindBitmap</h3>
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
查找 bitmap.
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-20 11:57:28 +00:00
2016-10-23 15:53:20 +00:00
bitmap;
2017-03-24 15:14:55 +00:00
rect (可选参数): x, y, w, h
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### Return:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
查找到, 返回 bitmap 的 x 和y 坐标; 没有返回 nil
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="OpenBitmap">.OpenBitmap</h3>
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
打开 bitmap 图片.
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
bitmap 图片路径,
MMImageType (可选)
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
返回一个 bitmap 对象
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="SaveBitmap">.SaveBitmap</h3>
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
保存一个 bitmap 图片.
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
bitmap 对象,
2016-10-22 11:29:41 +00:00
保存路径,
2017-03-24 15:14:55 +00:00
imagetype (int)
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
保存图片, 返回保存状态
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="TostringBitmap">.TostringBitmap</h3>
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
将一个 bitmap 对象转换为字符串对象.
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
bitmap 对象
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
#### Return:
2016-10-20 11:57:28 +00:00
2017-03-24 15:14:55 +00:00
返回一个 bitmap 字符串
2016-10-20 11:57:28 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="GetPortion">.GetPortion</h3>
2016-10-23 15:53:20 +00:00
bitmap from a portion
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-23 15:53:20 +00:00
bitmap,
rect: x, y, w, h
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-23 15:53:20 +00:00
Returns new bitmap object created from a portion of another
2017-04-30 05:54:38 +00:00
### <h3 id="Convert">.Convert(openpath, savepath, MMImageType)</h3>
2016-10-09 05:57:33 +00:00
2017-03-24 15:14:55 +00:00
转换 bitmap 图片格式
2016-10-30 11:26:56 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-30 11:26:56 +00:00
openpath,
savepath,
2017-03-24 15:14:55 +00:00
MMImageType (可选)
2016-10-30 11:26:56 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-30 11:26:56 +00:00
```Go
2017-03-15 08:41:45 +00:00
robotgo.Convert("test.png", "test.tif")
2016-10-30 11:26:56 +00:00
```
2017-06-03 14:14:36 +00:00
2017-06-07 12:44:52 +00:00
### <h3 id="FreeBitmap">.FreeBitmap(MMBitmapRef)</h3>
2017-06-03 14:14:36 +00:00
FreeBitmap free and dealloc bitmap
#### 参数:
2017-06-07 12:44:52 +00:00
MMBitmapRef
2017-06-03 14:14:36 +00:00
#### 示例:
```Go
robotgo.FreeBitmap(bitmap)
```
2017-06-07 12:44:52 +00:00
### <h3 id="ReadBitmap">.ReadBitmap(MMBitmapRef)</h3>
ReadBitmap returns false and sets error if |bitmap| is NULL
#### 参数:
MMBitmapRef
#### 返回值:
bool
#### 示例:
```Go
robotgo.ReadBitmap(bitmap)
```
### <h3 id="CopyBitpb">.CopyBitpb(MMBitmapRef)</h3>
CopyBitpb copy bitmap to pasteboard
#### 参数:
MMBitmapRef
#### 返回值:
bool
#### 示例:
```Go
robotgo.CopyBitpb(bitmap)
```
2017-06-30 14:54:07 +00:00
### <h3 id="DeepCopyBit">.DeepCopyBit(MMBitmapRef)</h3>
DeepCopyBit deep copy bitmap
#### 参数:
MMBitmapRef
#### 返回值:
MMBitmapRef
#### 示例:
```Go
robotgo.DeepCopyBit(bitmap)
```
2017-04-23 02:21:04 +00:00
## <h2 id="Event">事件</h2>
2016-10-30 13:35:01 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="AddEvent">.AddEvent(string)</h3>
2016-10-30 13:35:01 +00:00
监听全局事件
2017-03-15 08:41:45 +00:00
#### 参数:
2016-10-30 13:35:01 +00:00
string
2017-03-24 15:14:55 +00:00
(鼠标参数: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-10-30 13:35:01 +00:00
2017-03-24 15:14:55 +00:00
监听成功返回 0
2016-10-30 13:35:01 +00:00
2017-03-15 08:41:45 +00:00
#### 示例:
2016-10-30 13:35:01 +00:00
```Go
package main
import (
2017-03-04 16:19:09 +00:00
"fmt"
2016-10-30 13:35:01 +00:00
"github.com/go-vgo/robotgo"
)
func main() {
2016-11-12 07:56:07 +00:00
keve := robotgo.AddEvent("k")
if keve {
2017-03-04 16:19:09 +00:00
fmt.Println("you press...", "k")
2016-10-30 13:35:01 +00:00
}
2016-11-12 07:56:07 +00:00
mleft := robotgo.AddEvent("mleft")
if mleft {
2017-03-04 16:19:09 +00:00
fmt.Println("you press...", "mouse left button")
2016-10-30 13:35:01 +00:00
}
}
2016-11-07 08:46:22 +00:00
```
2017-03-15 08:41:45 +00:00
### <h3 id="StopEvent">.StopEvent()</h3>
2016-12-30 09:04:50 +00:00
停止事件监听
2017-03-15 08:41:45 +00:00
## <h2 id="Window">窗口</h2>
2016-11-07 08:46:22 +00:00
2017-04-30 05:54:38 +00:00
### <h3 id="ShowAlert">.ShowAlert(title, msg, defaultButton, cancelButton string)</h3>
2016-11-07 08:46:22 +00:00
Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed
2017-03-15 08:41:45 +00:00
#### 参数:
2016-11-07 08:46:22 +00:00
2017-03-24 15:14:55 +00:00
title (string),
msg (string),
defaultButton (optional string),
cancelButton (optional string)
2016-11-07 08:46:22 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-11-07 08:46:22 +00:00
2017-04-29 14:08:27 +00:00
Returns 0 (True) if the default button was pressed, or 1 (False) if cancelled.
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="CloseWindow">.CloseWindow()</h3>
2016-11-10 11:17:34 +00:00
2016-11-26 16:12:38 +00:00
关闭窗口
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:56:57 +00:00
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2017-01-24 15:56:57 +00:00
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="IsValid">.IsValid()</h3>
2016-11-10 11:17:34 +00:00
2017-04-29 14:20:48 +00:00
Valid the Window
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:56:57 +00:00
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2017-03-24 15:14:55 +00:00
如果窗口 selected 返回 true
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
### <h3 id="SetActive">.SetActive()</h3>
2016-11-23 12:40:28 +00:00
2017-04-29 14:20:48 +00:00
设为当前窗口
2016-11-23 12:40:28 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:56:57 +00:00
hwnd
2016-11-23 12:40:28 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-11-23 12:40:28 +00:00
void
2017-03-15 08:41:45 +00:00
### <h3 id="GetActive">.GetActive()</h3>
2016-11-10 11:17:34 +00:00
2017-04-29 14:08:27 +00:00
获取当前窗口
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:27:47 +00:00
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-11-10 11:17:34 +00:00
Returns hwnd
2017-03-15 08:41:45 +00:00
### <h3 id="SetHandle">.SetHandle()</h3>
2016-11-28 12:41:15 +00:00
2017-04-29 14:08:27 +00:00
Set the Window Handle
2016-11-28 12:41:15 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-11-28 12:41:15 +00:00
int
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-11-28 12:41:15 +00:00
bool
2017-03-15 08:41:45 +00:00
### <h3 id="GetHandle">.GetHandle()</h3>
2016-11-10 11:17:34 +00:00
2017-04-29 14:08:27 +00:00
获取窗口 Handle
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:27:47 +00:00
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2016-11-10 11:17:34 +00:00
Returns hwnd
2017-03-15 08:41:45 +00:00
### <h3 id="GetTitle">.GetTitle()</h3>
2016-11-10 11:17:34 +00:00
2017-04-29 14:08:27 +00:00
获取窗口标题
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2016-11-10 11:17:34 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2017-01-18 12:41:39 +00:00
返回窗口标题
2017-03-15 08:41:45 +00:00
### <h3 id="GetPID">.GetPID()</h3>
2017-01-18 12:41:39 +00:00
2017-04-29 14:08:27 +00:00
获取进程 id
2017-01-18 12:41:39 +00:00
2017-03-15 08:41:45 +00:00
#### 参数:
2017-01-24 15:27:47 +00:00
2017-01-18 12:41:39 +00:00
2017-03-15 08:41:45 +00:00
#### 返回值:
2017-07-25 15:16:24 +00:00
返回进程 id
### <h3 id="Pids">.Pids()</h3>
获取所有进程 id
#### 参数:
#### 返回值:
返回进程 id
### <h3 id="PidExists">.PidExists()</h3>
判断进程 id 是否存在
#### 参数:
pid
#### 返回值:
2017-08-03 14:43:21 +00:00
返回 bool
### <h3 id="Process">.Process()</h3>
Process get the all process struct
#### 参数:
#### 返回值:
Returns []Nps, error
### <h3 id="FindName">.FindName()</h3>
FindName find the process name by the process id
#### 参数:
pid
#### 返回值:
2017-08-21 14:51:42 +00:00
Returns string, error
### <h3 id="FindNames">.FindNames()</h3>
FindNames find the all process name
#### Arguments:
none
#### Return:
Returns []string, error
### <h3 id="FindIds">.FindIds()</h3>
FindIds find the process id by the process name
#### Arguments:
name string
#### Return:
2017-10-03 12:17:35 +00:00
Returns []int32, error
### <h3 id="ActivePID">.ActivePID()</h3>
ActivePID window active by PID
#### Arguments:
pid int32
#### Return:
none