General purpose macro utility made in Golang, with scripts in Javascript.
This tool was created as a way to learn the language and test the workflow for a single-binary, HTML/CSS/JS desktop application with Go as backend.
Still in early development. It has basic mouse, keyboard and screen capture functionality.
Example of a script that picks colors and draws random points inside a mspaint window:
Tested on Windows 64-bits with Chrome installed, required by lorca
.
For pre-compiled binaries for windows, check the Releases page.
If you want to build it yourself, you need to install robotgo dependencies first, check their documentation for a tutorial. After that, you can build go-macros with:
git clone https://github.com/haroflow/go-macros.git
cd go-macros
go build .
// Capture a portion of the screen around the mouse cursor for 10 seconds, log the screen capture in the log window.
for (var i = 0; i < 10; i++) {
var x = mouse.getX();
var y = mouse.getY();
log.text("Capturing screen at (" + x + ", " + y + ")");
var img = screen.captureRect(x, y, 100, 100);
log.image(img);
sleep(1000);
}
log.text("Finished!")
// Open notepad and write a message
keyboard.press("r", "cmd"); // "cmd" = Windows key
sleep(1000);
keyboard.type("notepad");
sleep(1000);
keyboard.press("enter");
sleep(1000);
keyboard.type("Hello go-macros!")
You can check the autogenerated documentation by clicking the Help
button inside the application.
Summary of the currently supported commands:
mouse.move
mouse.moveSmooth
mouse.moveRelative
mouse.click
mouse.rightClick
mouse.doubleClick
mouse.drag
mouse.dragRelative
mouse.getX
mouse.getY
keyboard.type
keyboard.press
screen.capture
screen.captureRect
screen.getPixelColor
screen.getWidth
screen.getHeight
screen.search
screen.searchAll
image.saveJpeg
image.savePng
color.getBrightness
color.distance
sleep
log.text
log.image
- Better error handling. When running the macro with F2 it's not showing javascript errors on the UI.
- Clipboard manipulation. Should be easy, robotgo already has functions for it.
- More image and color manipulation functions:
- adjustBrightness
- adjustContrast
- toGrayscale
- sharpen
- blur
- Window manipulation:
- Find window by title.
- Bring window to front.
- Maximize/minimize active window.
- File and directory manipulation.
- Add OCR functions, robotgo supports this using the tesseract cli. Is there a way to not depend on another installation?
- Rework the UI:
- Allow creating/saving/deleting scripts.
- Show list of scripts.
- Allow setting a hotkey for each script.
- Unify Run and Stop buttons.
- Maybe remove the autogenerated documentation? I was hoping it would force the developer to write documentation for new commands... But I don't think it reaaally helps, and only adds to code size. Maybe a tool like
go doc
would be better.