# Methods:
##### [GetVersion](#GetVersion)
## [Keyboard](#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](#Mouse)
##### [SetMouseDelay](#SetMouseDelay)
##### [MoveMouse](#MoveMouse)
##### [Move](#MoveMouse) (Equivalent to MoveMouse)
##### [MoveMouseSmooth](#MoveMouseSmooth)
##### [MoveSmooth](#MoveMouseSmooth) (Equivalent to MoveMouseSmooth)
##### [MouseClick](#MouseClick)
##### [Click](#MouseClick) (Equivalent to MouseClick)
##### [MoveClick](#MoveClick)
##### [MouseToggle](#MouseToggle)
##### [DragMouse](#DragMouse)
##### [Drag](#DragMouse) (Equivalent to DragMouse)
##### [GetMousePos](#GetMousePos)
##### [ScrollMouse](#ScrollMouse)
## [Screen](#Screen)
##### [GetPixelColor](#GetPixelColor)
##### [GetScreenSize](#GetScreenSize)
##### [CaptureScreen](#CaptureScreen)
##### [GetXDisplayName(Linux)](#GetXDisplayName)
##### [SetXDisplayName(Linux)](#SetXDisplayName)
## [Bitmap](#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](#Event)
##### [AddEvent](#AddEvent)
##### [StopEvent](#StopEvent)
## [Window](#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)
###
.GetVersion()
Get robotgo version
## Keyboard
### .SetKeyDelay(ms)
Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.
#### Arguments:
ms - Time to sleep in milliseconds.
### .KeyTap(key, modifier)
Press a single key.
#### Arguments:
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.
#### Examples:
```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.
#### Arguments:
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.
#### Return:
return KeyToggle status
### .TypeStr(string)
#### Arguments:
string - The string to send.
### .TypeStrDelay(string, cpm)
#### Arguments:
string - The string to send.
cpm - Characters per minute.
### .WriteAll(text string)
#### Arguments:
text string
#### Return:
### .ReadAll()
#### Arguments:
#### Return:
text,
error
## Mouse
### .SetMouseDelay(ms)
Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.
#### Arguments:
ms - Time to sleep in milliseconds.
### .MoveMouse(x, y)
Moves mouse to x, y instantly, with the mouse button up.
#### Arguments:
x, y
#### Examples:
```Go
// Move the mouse to 100, 100 on the screen.
robotgo.MoveMouse(100, 100)
```
### .MoveMouseSmooth(x, y)
Moves mouse to x, y human like, with the mouse button up.
#### Arguments:
x, y
lowspeed, highspeed
#### Examples:
```Go
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
```
### .MouseClick(button, double)
Clicks the mouse.
#### Arguments:
button (optional) - Accepts "left", "right", or "center". Defaults to left.
double (optional) - Set to true to perform a double click. Defaults to false.
#### Examples:
```Go
robotgo.MouseClick()
robotgo.MouseClick("left", true)
```
### .MoveClick(x, y, button, double)
Move and click the mouse.
#### Arguments:
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.
#### Examples:
```Go
robotgo.MoveClick(10, 20)
robotgo.MoveClick(10, 20, "left", true)
```
### .MouseToggle(down, button)
Toggles mouse button.
#### Arguments:
down (optional) - Accepts down or up. Defaults to down.
button (optional) - Accepts "left", "right", or "center". Defaults to left.
#### Examples:
```Go
robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right")
```
### .DragMouse(x, y)
Moves mouse to x, y instantly, with the mouse button held down.
#### Arguments:
x, y
#### Examples:
```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.
#### Return:
Returns an object with keys x and y.
#### Examples:
```Go
x,y := robotgo.GetMousePos()
fmt.Println("pos:", x, y)
```
###
Scrolls the mouse either up or down.
#### Arguments:
magnitude - The amount to scroll.
direction - Accepts down or up.
#### Examples:
```Go
robotgo.ScrollMouse(50, "up")
robotgo.ScrollMouse(50, "down")
```
## Screen
### .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.
#### Arguments:
x, y
#### Return:
Returns the hex color code of the pixel at x, y.
### .GetScreenSize()
Gets the screen width and height.
#### Return:
Returns an object with .width and .height.
### .CaptureScreen
// CaptureScreen
Gets part or all of the screen.
GoCaptureScreen Returns a go struct
#### Arguments:
x (optional)
y (optional)
height (optional)
width (optional)
If no arguments are provided, capturescreen(screencapture) will get the full screen.
#### Return:
Returns a bitmap object.
## Bitmap
This is a work in progress.
### .FindBitmap
find bitmap.
#### Arguments:
bitmap;
rect(optional): x, y, w, h
#### Return:
Returns a position x and y
### .OpenBitmap
open bitmap.
#### Arguments:
bitmap image path,
MMImageType (optional)
#### Return:
Returns a bitmap
### .SaveBitmap
Save a image with bitmap.
#### Arguments:
bitmap,
path,
imagetype (int)
#### Return:
return save image status
### .TostringBitmap
bitmap to string
#### Arguments:
bitmap
#### Return:
Return a sting bitmap
### .GetPortion
bitmap from a portion
#### Arguments:
bitmap,
rect: x, y, w, h
#### Return:
Returns new bitmap object created from a portion of another
### .Convert(openpath, savepath, MMImageType)
Convert the image format
#### Arguments:
openpath,
savepath,
MMImageType (optional)
#### Examples:
```Go
robotgo.Convert("test.png", "test.tif")
```
### .FreeBitmap(MMBitmapRef)
FreeBitmap free and dealloc bitmap
#### Arguments:
MMBitmapRef
#### Examples:
```Go
robotgo.FreeBitmap(bitmap)
```
### .ReadBitmap(MMBitmapRef)
ReadBitmap returns false and sets error if |bitmap| is NULL
#### Arguments:
MMBitmapRef
#### Return:
bool
#### Examples:
```Go
robotgo.ReadBitmap(bitmap)
```
### .CopyBitpb(MMBitmapRef)
CopyBitpb copy bitmap to pasteboard
#### Arguments:
MMBitmapRef
#### Return:
bool
#### Examples:
```Go
robotgo.CopyBitpb(bitmap)
```
### .DeepCopyBit(MMBitmapRef)
DeepCopyBit deep copy bitmap
#### Arguments:
MMBitmapRef
#### Return:
MMBitmapRef
#### Examples:
```Go
robotgo.DeepCopyBit(bitmap)
```
## Event
### .AddEvent(string)
Listening global event
#### Arguments:
string
(mouse arguments: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)
#### Return:
if listened return 0
#### Examples:
```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()
stop listen global event
## Window
### .ShowAlert(title, msg, defaultButton, cancelButton string)
Displays alert with the given attributes. If cancelButton is not given, only the defaultButton is displayed
#### Arguments:
title (string),
msg (string),
defaultButton (optional string),
cancelButton (optional string)
#### Return:
Returns 0(True) if the default button was pressed, or 1(False) if cancelled.
### .CloseWindow()
Close the Window
#### Arguments:
None
#### Return:
None
### .IsValid()
Valid the Window
#### Arguments:
None
#### Return:
Returns true if a window has been selected
### .SetActive()
Set the Active Window
#### Arguments:
hwnd
#### Return:
void
### .GetActive()
Get the Active Window
#### Arguments:
None
#### Return:
Returns hwnd
### .SetHandle()
Set the Window Handle
#### Arguments:
int
#### Return:
bool
### .GetHandle()
Get the Window Handle
#### Arguments:
None
#### Return:
Returns hwnd
### .GetTitle()
Get the Window Title
#### Arguments:
None
#### Return:
Returns Window Title
### .GetPID()
Get the process id
#### Arguments:
None
#### Return:
Returns the process id
### .Pids()
Pids get the all process id
#### Arguments:
None
#### Return:
Returns all process id
### .PidExists()
PidExists determine whether the process exists
#### Arguments:
pid
#### Return:
Returns bool
### .Process()
Process get the all process struct
#### Arguments:
none
#### Return:
Returns []Nps, error
### .FindName()
FindName find the process name by the process id
#### Arguments:
pid
#### Return:
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