项目作者: vcaesar

项目描述 :
Robotn, Native cross-platform GUI automation
高级语言: JavaScript
项目地址: git://github.com/vcaesar/robotn.git
创建时间: 2019-03-05T17:39:36Z
项目社区:https://github.com/vcaesar/robotn

开源协议:Apache License 2.0

下载


Robotn

Build Status
CircleCI Status
Appveyor
Go Report Card
GoDoc
GitHub release
Join the chat at https://gitter.im/go-vgo/robotgo

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

Robotn supports Mac, Windows, and Linux(X11). Robot supports go, javascript, python and other.

简体中文

Contents

Docs

Requirements:

Now, there is no prebuild binary version available, Please make sure Golang, GCC is installed correctly before installing robotgo.

Robotgo Requirements

Install robotn

  1. npm install robotn

Also, you can Build from source code. The python’s pip install, and the prebuilt binaries will be added in the future.

Examples:

Mouse

  1. var robot = require('robotn');
  2. robot.scroll(10, 10);
  3. robot.mouseClick("left", true);
  4. robot.moveSmooth(100, 200, 1.0, 100.0);

python

  1. import robot
  2. robot.scroll(10, 10)
  3. robot.mouseClick("left", true)
  4. robot.moveSmooth(100, 200, 1.0, 100.0)

Keyboard

  1. var robot = require('robotn');
  2. robot.typeStr("测试")
  3. robot.typeStr("山达尔星新星军团, galaxy. こんにちは世界.")
  4. robot.sleep(1)
  5. robot.keyTap("enter")
  6. robot.writeAll("Test")
  7. var text = robot.readAll()
  8. console.log(text)

Screen

  1. var robot = require('robotn');
  2. var pos = robot.getMousePos()
  3. console.log("pos: ", pos)
  4. var color = robot.getPixelColor(100, 200)
  5. console.log("color---- ", color)

Bitmap

  1. var robot = require('robotn');
  2. var bitmap = robot.captureScreen(10, 20, 30, 40)
  3. console.log("...", bitmap)
  4. var pos = robot.findBitmap(bitmap)
  5. console.log("FindBitmap------ ", pos)
  6. robot.saveBitmap(bitmap, "test.png")
  7. // use `robot.freeBitmap(bit)` to free the bitmap
  8. robot.freeBitmap(bitmap)

Event

  1. var robot = require('robotn');
  2. var keve = robot.addEvent("k");
  3. if (keve) {
  4. console.log("you press... ", "k");
  5. }
  6. var s = robot.addEvents("q", "ctrl");
  7. if (s) {
  8. console.log("you press... ", "mouse left button");
  9. }

Window

  1. var robot = require('robotn');
  2. var fpid = robot.findIds("Google")
  3. console.log("pids... ", fpid)
  4. if (fpid.length > 0) {
  5. robot.activePID(fpid[0])
  6. robot.kill(fpid[0])
  7. }
  8. robot.activeName("chrome")
  9. var isExist = robot.pidExists(100)
  10. if (isExist) {
  11. console.log("pid exists is", isExist)
  12. robot.kill(100)
  13. }
  14. var abool = robot.showAlert("test", "robotgo")
  15. if (abool == 0) {
  16. console.log("ok@@@ ", "ok")
  17. }
  18. var title = robot.getTitle()
  19. console.log("title@@@ ", title)

Build from source code:

Install robotgo

  1. go get -u github.com/go-vgo/robotgo
  1. git clone https://github.com/vcaesar/robotn

Build-tools

  1. go get -v github.com/vcaesar/gocs

Building

  1. cd robotn
  1. gocs -n robotgo

node:

Install npm modules
  1. npm install

python

  1. pip install cffi

Authors

Plans

  • Update Find an image on screen, read pixels from an image
  • Update Window Handle
  • Try support Android, maybe support IOS

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.