Fix doc.md

This commit is contained in:
vCaesar 2017-03-15 16:25:55 +08:00
parent 6f8e16b42b
commit 3a04f0ca44

View File

@ -1,82 +1,82 @@
#Methods: # Methods:
#####[GetVersion](#GetVersion) ##### [GetVersion](#GetVersion)
##[Keyboard](#Keyboard) ## [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)(Equivalent to SetKeyDelay,Wno-deprecated) ##### [SetKeyboardDelay](#SetKeyDelay)(Equivalent to SetKeyDelay,Wno-deprecated)
#####[SetKeyDelay](#SetKeyDelay) ##### [SetKeyDelay](#SetKeyDelay)
#####[KeyTap](#KeyTap) ##### [KeyTap](#KeyTap)
#####[KeyToggle](#KeyToggle) ##### [KeyToggle](#KeyToggle)
#####[TypeString](#TypeString) ##### [TypeString](#TypeString)
#####[TypeStringDelayed](#TypeStrDelay)(Equivalent to TypeStrDelay,Wno-deprecated) ##### [TypeStringDelayed](#TypeStrDelay)(Equivalent to TypeStrDelay,Wno-deprecated)
#####[TypeStrDelay](#TypeStrDelay) ##### [TypeStrDelay](#TypeStrDelay)
##[Mouse](#Mouse) ## [Mouse](#Mouse)
#####[SetMouseDelay](#SetMouseDelay) ##### [SetMouseDelay](#SetMouseDelay)
#####[MoveMouse](#MoveMouse) ##### [MoveMouse](#MoveMouse)
#####[Move](#MoveMouse)(Equivalent to MoveMouse) ##### [Move](#MoveMouse)(Equivalent to MoveMouse)
#####[MoveMouseSmooth](#MoveMouseSmooth) ##### [MoveMouseSmooth](#MoveMouseSmooth)
#####[MoveSmooth](#MoveMouseSmooth)(Equivalent to MoveMouseSmooth) ##### [MoveSmooth](#MoveMouseSmooth)(Equivalent to MoveMouseSmooth)
#####[MouseClick](#MouseClick) ##### [MouseClick](#MouseClick)
#####[Click](#MouseClick)(Equivalent to MouseClick) ##### [Click](#MouseClick)(Equivalent to MouseClick)
#####[MoveClick](#MoveClick) ##### [MoveClick](#MoveClick)
#####[MouseToggle](#MouseToggle) ##### [MouseToggle](#MouseToggle)
#####[DragMouse](#DragMouse) ##### [DragMouse](#DragMouse)
#####[Drag](#DragMouse)(Equivalent to DragMouse) ##### [Drag](#DragMouse)(Equivalent to DragMouse)
#####[GetMousePos](#GetMousePos) ##### [GetMousePos](#GetMousePos)
#####[ScrollMouse](#ScrollMouse) ##### [ScrollMouse](#ScrollMouse)
##[Screen](#Screen) ## [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) ## [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) ## [Event](#Event)
#####[LEvent](#LEvent)(Equivalent to AddEvent,Wno-deprecated) ##### [LEvent](#LEvent)(Equivalent to AddEvent,Wno-deprecated)
#####[AddEvent](#AddEvent) ##### [AddEvent](#AddEvent)
#####[StopEvent](#StopEvent) ##### [StopEvent](#StopEvent)
##[Window](#Window) ## [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)
###<h3 id="GetVersion">.GetVersion()</h3> ### <h3 id="GetVersion">.GetVersion()</h3>
get robotgo version get robotgo version
##<h2 id="Keyboard">Keyboard</h2> ## <h2 id="Keyboard">Keyboard</h2>
###<h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3> ### <h3 id="SetKeyDelay">.SetKeyDelay(ms)</h3>
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.
####Arguments: #### Arguments:
ms - Time to sleep in milliseconds. ms - Time to sleep in milliseconds.
@ -84,148 +84,148 @@
Press a single key. Press a single key.
####Arguments: #### Arguments:
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.
####Examples: #### Examples:
```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.
####Arguments: #### Arguments:
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.
####Return: #### Return:
return KeyToggle status return KeyToggle status
###<h3 id="TypeString">.TypeString(string)</h3> ### <h3 id="TypeString">.TypeString(string)</h3>
####Arguments: #### Arguments:
string - The string to send. string - The string to send.
###<h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3> ### <h3 id="TypeStrDelay">.TypeStrDelay(string, cpm)</h3>
####Arguments: #### Arguments:
string - The string to send. string - The string to send.
cpm - Characters per minute. cpm - Characters per minute.
##<h2 id="Mouse">Mouse</h2> ## <h2 id="Mouse">Mouse</h2>
###<h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3> ### <h3 id="SetMouseDelay">.SetMouseDelay(ms)</h3>
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.
####Arguments: #### Arguments:
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.
####Arguments: #### Arguments:
x,y x,y
####Examples: #### Examples:
```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>
Moves mouse to x, y human like, with the mouse button up. Moves mouse to x, y human like, with the mouse button up.
####Arguments: #### Arguments:
x,y x,y
lowspeed,highspeed lowspeed,highspeed
####Examples: #### Examples:
```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.
####Arguments: #### Arguments:
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.
####Examples: #### Examples:
```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>
Move and click the mouse. Move and click the mouse.
####Arguments: #### Arguments:
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.
####Examples: #### Examples:
```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.
####Arguments: #### Arguments:
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.
####Examples: #### Examples:
```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.
####Arguments: #### Arguments:
x,y x,y
####Examples: #### Examples:
```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.
@ -235,31 +235,31 @@ 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.
####Return: #### Return:
Returns an object with keys x and y. Returns an object with keys x and y.
####Examples: #### Examples:
```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.
####Arguments: #### Arguments:
magnitude - The amount to scroll. magnitude - The amount to scroll.
direction - Accepts down or up. direction - Accepts down or up.
####Examples: #### Examples:
```Go ```Go
robotgo.ScrollMouse(50, "up") robotgo.ScrollMouse(50, "up")
@ -268,29 +268,29 @@ robotgo.ScrollMouse(50, "down")
``` ```
##<h2 id="Screen">Screen</h2> ## <h2 id="Screen">Screen</h2>
###<h3 id="GetPixelColor">.GetPixelColor(x, y) ### <h3 id="GetPixelColor">.GetPixelColor(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.
####Arguments: #### Arguments:
x,y x,y
####Return: #### Return:
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.
####Return: #### Return:
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.
@ -298,7 +298,7 @@ robotgo.ScrollMouse(50, "down")
BCaptureScreen Returns a go struct BCaptureScreen Returns a go struct
Capture_Screen(Drop support) Capture_Screen(Drop support)
####Arguments: #### Arguments:
x (optional) x (optional)
y (optional) y (optional)
@ -306,114 +306,114 @@ robotgo.ScrollMouse(50, "down")
width (optional) width (optional)
If no arguments are provided, screencapture will get the full screen. If no arguments are provided, screencapture will get the full screen.
####Return: #### Return:
Returns a bitmap object. Returns a bitmap object.
##<h2 id="Bitmap">Bitmap</h2> ## <h2 id="Bitmap">Bitmap</h2>
This is a work in progress. This is a work in progress.
###<h3 id="FindBitmap">.FindBitmap</h3> ### <h3 id="FindBitmap">.FindBitmap</h3>
find bitmap. find bitmap.
####Arguments: #### Arguments:
bitmap; bitmap;
rect(optional): x, y, w, h rect(optional): x, y, w, h
####Return: #### Return:
Returns a position x and y Returns a position x and y
###<h3 id="OpenBitmap">.OpenBitmap</h3> ### <h3 id="OpenBitmap">.OpenBitmap</h3>
open bitmap. open bitmap.
####Arguments: #### Arguments:
bitmap image path, bitmap image path,
MMImageType(optional) MMImageType(optional)
####Return: #### Return:
Returns a bitmap Returns a bitmap
###<h3 id="SaveBitmap">.SaveBitmap</h3> ### <h3 id="SaveBitmap">.SaveBitmap</h3>
save a image with bitmap. save a image with bitmap.
####Arguments: #### Arguments:
bitmap, bitmap,
path, path,
imagetype(int) imagetype(int)
####Return: #### Return:
return save image status return save image status
###<h3 id="TostringBitmap">.TostringBitmap</h3> ### <h3 id="TostringBitmap">.TostringBitmap</h3>
bitmap to string bitmap to string
####Arguments: #### Arguments:
bitmap bitmap
####Return: #### Return:
Return a sting bitmap Return a sting bitmap
###<h3 id="GetPortion">.GetPortion</h3> ### <h3 id="GetPortion">.GetPortion</h3>
bitmap from a portion bitmap from a portion
####Arguments: #### Arguments:
bitmap, bitmap,
rect: x, y, w, h rect: x, y, w, h
####Return: #### Return:
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>
Convert the image format Convert the image format
####Arguments: #### Arguments:
openpath, openpath,
savepath, savepath,
MMImageType(optional) MMImageType(optional)
####Examples: #### Examples:
```Go ```Go
robotgo.Convert("test.png", "test.tif") robotgo.Convert("test.png", "test.tif")
``` ```
##<h2 id="Event">Event</h2> ## <h2 id="Event">Event</h2>
###<h3 id="AddEvent">.AddEvent(string)</h3> ### <h3 id="AddEvent">.AddEvent(string)</h3>
Listening global event Listening global event
####Arguments: #### Arguments:
string string
(mosue arguments:mleft mright wheelDown wheelUp wheelLeft wheelRight) (mosue arguments:mleft mright wheelDown wheelUp wheelLeft wheelRight)
####Return: #### Return:
if listened return 0 if listened return 0
####Examples: #### Examples:
```Go ```Go
package main package main
@ -436,16 +436,16 @@ func main() {
} }
} }
``` ```
###<h3 id="StopEvent">.StopEvent()</h3> ### <h3 id="StopEvent">.StopEvent()</h3>
stop listen global event stop listen global event
##<h2 id="Window">Window</h2> ## <h2 id="Window">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
####Arguments: #### Arguments:
title(string), title(string),
msg(string), msg(string),
@ -453,89 +453,89 @@ func main() {
cancelButton(optional string) cancelButton(optional string)
####Return: #### Return:
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>
Close the Window Close the Window
####Arguments: #### Arguments:
None None
####Return: #### Return:
None None
###<h3 id="IsValid">.IsValid()</h3> ### <h3 id="IsValid">.IsValid()</h3>
Valid the Window Valid the Window
####Arguments: #### Arguments:
None None
####Return: #### Return:
Returns true if a window has been selected Returns true if a window has been selected
###<h3 id="SetActive">.SetActive()</h3> ### <h3 id="SetActive">.SetActive()</h3>
Set the Active Window Set the Active Window
####Arguments: #### Arguments:
hwnd hwnd
####Return: #### Return:
void void
###<h3 id="GetActive">.GetActive()</h3> ### <h3 id="GetActive">.GetActive()</h3>
Get the Active Window Get the Active Window
####Arguments: #### Arguments:
None None
####Return: #### Return:
Returns hwnd Returns hwnd
###<h3 id="SetHandle">.SetHandle()</h3> ### <h3 id="SetHandle">.SetHandle()</h3>
Set the Window Handle Set the Window Handle
####Arguments: #### Arguments:
int int
####Return: #### Return:
bool bool
###<h3 id="GetHandle">.GetHandle()</h3> ### <h3 id="GetHandle">.GetHandle()</h3>
Get the Window Handle Get the Window Handle
####Arguments: #### Arguments:
None None
####Return: #### Return:
Returns hwnd Returns hwnd
###<h3 id="GetTitle">.GetTitle()</h3> ### <h3 id="GetTitle">.GetTitle()</h3>
Get the Window Title Get the Window Title
####Arguments: #### Arguments:
None None
####Return: #### Return:
Returns Window Title Returns Window Title
###<h3 id="GetPID">.GetPID()</h3> ### <h3 id="GetPID">.GetPID()</h3>
Get the process id Get the process id
####Arguments: #### Arguments:
None None
####Return: #### Return:
Returns the process id Returns the process id