Golang 跨平台自动化系统,控制键盘、鼠标、位图、图像、读取屏幕,进程、窗口句柄以及全局事件监听。

vcaesar 6f4ab42757 Remove bitmap 7 年之前
.github 58efd059d2 Update README.md and issue_temp 7 年之前
base 5a80dd3332 Update clipboard and add CYGWIN 7 年之前
bitmap ea0b910646 Add find some color 7 年之前
clipboard 6f13aded25 Update test 7 年之前
docs e1b1d554dd Update docs 7 年之前
event f311cf8810 Format some code 7 年之前
examples 6f4ab42757 Remove bitmap 7 年之前
key 8fe2f76d8c Fix release key 7 年之前
mouse 9298b9bc17 Format some code 7 年之前
screen 9298b9bc17 Format some code 7 年之前
test 6f4ab42757 Remove bitmap 7 年之前
vendor 29c6d82cd7 Update vendor 7 年之前
window 6e3a4db36a Update pid type and fix windows err 7 年之前
.gitignore 44aca8f2f3 Update .gitignore 7 年之前
.travis.yml 6f4ab42757 Remove bitmap 7 年之前
CONTRIBUTING.md 529e382e7b Update Contribution.md 7 年之前
LICENSE 6c790bdaf4 Update LICENSE 7 年之前
README.md 6f4ab42757 Remove bitmap 7 年之前
README_zh.md 6f4ab42757 Remove bitmap 7 年之前
circle.yml 6f4ab42757 Remove bitmap 7 年之前
robotgo.go 6f4ab42757 Remove bitmap 7 年之前

README.md

Robotgo

Build Status CircleCI Status Go Report Card GoDoc Release

Golang Desktop Automation. Control the mouse, keyboard, bitmap, read the screen, Window Handle and global event listener.

RobotGo supports Mac, Windows, and Linux(X11).

This is a work in progress.

简体中文

Contents

Docs

Requirements:

Now, Please make sure Golang, GCC is installed correctly before installing RobotGo.

ALL:

Golang
GCC

For Mac OS X:

    Xcode Command Line Tools

For Windows:

MinGW or other GCC

For everything else:

GCC
    
X11 with the XTest extension (also known as the Xtst library)

Event:
    
xcb, xkb, libxkbcommon
Ubuntu:
sudo apt-get install gcc libc6-dev

sudo apt-get install libx11-dev
sudo apt-get install xorg-dev  

sudo apt-get install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev
sudo apt-get install libxkbcommon-dev

sudo apt-get install xsel
sudo apt-get install xclip

Fedora:

sudo dnf install libxkbcommon-devel libXtst-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel

sudo dnf install xsel
sudo dnf install xclip

Installation:

go get github.com/go-vgo/robotgo

It's that easy!

Update:

go get -u github.com/go-vgo/robotgo  

Examples:

Mouse

package main

import (
	"github.com/go-vgo/robotgo"
)

func main() {
  robotgo.ScrollMouse(10, "up")
  robotgo.MouseClick("left", true)
  robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0)
} 

Keyboard

package main

import (
  "fmt"

  "github.com/go-vgo/robotgo"
)

func main() {
  robotgo.TypeString("Hello World")
  robotgo.KeyTap("enter")
  robotgo.TypeString("en")
  robotgo.KeyTap("i", "alt", "command")
  arr := []string{"alt", "command"}
  robotgo.KeyTap("i", arr)

  robotgo.WriteAll("Test")
  text, err := robotgo.ReadAll()
  if err == nil {
    fmt.Println(text)
  }
} 

Screen

package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  x, y := robotgo.GetMousePos()
  fmt.Println("pos:", x, y)
  color := robotgo.GetPixelColor(100, 200)
  fmt.Println("color----", color)
} 

Event

package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  keve := robotgo.AddEvent("k")
  if keve == 0 {
    fmt.Println("you press...", "k")
  }

  mleft := robotgo.AddEvent("mleft")
  if mleft == 0 {
    fmt.Println("you press...", "mouse left button")
  }
} 

Window

package main

import (
	"fmt"

	"github.com/go-vgo/robotgo"
)

func main() {
  fpid, err := robotgo.FindIds("Google")
  if err == nil {
    fmt.Println("pids...", fpid)
  }

  isExist, err := robotgo.PidExists(100)
  if err == nil {
    fmt.Println("pid exists is", isExist)
  }

  abool := robotgo.ShowAlert("test", "robotgo")
  if abool == 0 {
 	  fmt.Println("ok@@@", "ok")
  }

  title := robotgo.GetTitle()
  fmt.Println("title@@@", title)
} 

Plans

  • Update Find an image on screen, read pixels from an image
  • Update Window Handle
  • Support UTF-8, transitional plan: TypeStr
  • Try support Android, maybe support IOS
  • Remove zlib/libpng dependencies

Donate

Supporting robotgo, buy me a coffee.

Paypal

Donate money by paypal to my account vzvway@gmail.com

Contributors

License

Robotgo is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT.