Move (Equivalent to MoveMouse)
MoveSmooth (Equivalent to MoveMouseSmooth)
Click (Equivalent to MouseClick)
Drag (Equivalent to DragMouse)
This is a work in progress.
This is a work in progress.
Get robotgo version
Sets the delay in milliseconds to sleep after a keyboard event. This is 10ms by default.
ms - Time to sleep in milliseconds.
Press a single key.
key - See keys.
modifier (optional, string or array) - Accepts alt, command (win), control, and shift.
robotgo.KeyTap("h", "command")
robotgo.KeyTap("i", "alt", "command")
arr := []string{"alt", "command"}
robotgo.KeyTap("i", arr)
Hold down or release a key.
key - See keys.
down - Accepts 'down' or 'up'.
modifier (optional, string or array) - Accepts alt, command (mac), control, and shift.
return KeyToggle status
string - The string to send.
string - The string to send.
cpm - Characters per minute.
text string
text,
error
Sets the delay in milliseconds to sleep after a mouse event. This is 10ms by default.
ms - Time to sleep in milliseconds.
Moves mouse to x, y instantly, with the mouse button up.
x, y
// Move the mouse to 100, 100 on the screen.
robotgo.MoveMouse(100, 100)
Moves mouse to x, y human like, with the mouse button up.
x, y
lowspeed, highspeed
robotgo.MoveMouseSmooth(100, 200)
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
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.
robotgo.MouseClick()
robotgo.MouseClick("left", true)
Move and click the mouse.
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.
robotgo.MoveClick(10, 20)
robotgo.MoveClick(10, 20, "left", true)
Toggles mouse button.
down (optional) - Accepts down or up. Defaults to down.
button (optional) - Accepts "left", "right", or "center". Defaults to left.
robotgo.MouseToggle("down")
robotgo.MouseToggle("down", "right")
Moves mouse to x, y instantly, with the mouse button held down.
x, y
// 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")
Gets the mouse coordinates.
Returns an object with keys x and y.
x,y := robotgo.GetMousePos()
fmt.Println("pos:", x, y)
Scrolls the mouse either up or down.
magnitude - The amount to scroll.
direction - Accepts down or up.
robotgo.ScrollMouse(50, "up")
robotgo.ScrollMouse(50, "down")
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.
Gets the screen width and height.
Returns an object with .width and .height.
// 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.
Returns a bitmap object.
This is a work in progress.
find bitmap.
bitmap;
rect(optional): x, y, w, h
Returns a position x and y
open bitmap.
bitmap image path,
MMImageType (optional)
Returns a bitmap
Save a image with bitmap.
bitmap,
path,
imagetype (int)
return save image status
bitmap to string
bitmap
Return a sting bitmap
bitmap from a portion
bitmap,
rect: x, y, w, h
Returns new bitmap object created from a portion of another
Convert the image format
openpath,
savepath,
MMImageType (optional)
robotgo.Convert("test.png", "test.tif")
FreeBitmap free and dealloc bitmap
MMBitmapRef
robotgo.FreeBitmap(bitmap)
ReadBitmap returns false and sets error if |bitmap| is NULL
MMBitmapRef
bool
robotgo.ReadBitmap(bitmap)
CopyBitpb copy bitmap to pasteboard
MMBitmapRef
bool
robotgo.CopyBitpb(bitmap)
DeepCopyBit deep copy bitmap
MMBitmapRef
MMBitmapRef
robotgo.DeepCopyBit(bitmap)
Listening global event
string
(mouse arguments: mleft, mright, wheelDown, wheelUp, wheelLeft, wheelRight)
if listened return 0
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")
}
}
stop listen global event
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.
Close the Window
None
None
Valid the Window
None
Returns true if a window has been selected
Set the Active Window
hwnd
void
Get the Active Window
None
Returns hwnd
Set the Window Handle
int
bool
Get the Window Handle
None
Returns hwnd
Get the Window Title
None
Returns Window Title
Get the process id
None
Returns the process id
Pids get the all process id
None
Returns all process id
PidExists determine whether the process exists
pid
Returns bool
Process get the all process struct
none
Returns []Nps, error
FindName find the process name by the process id
pid
Returns string, error
FindNames find the all process name
none
Returns []string, error
FindIds find the process id by the process name
name string
Returns []int32, error
ActivePID window active by PID
pid int32
none