Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control the mouse and keyboard Golang?

Tags:

go

mouse

How would one go about controlling retrieving/setting the position of the mouse and triggier keyboard events on the operating system/X11 level? This is similar to functionality found in the Robot class in Java.

I understand there will most likely not be a cross platform solution, but how would one go about implementing this on Windows, Linux and Mac?

like image 908
Hakkar Avatar asked Oct 19 '14 01:10

Hakkar


3 Answers

Please see robotgo, Golang Native cross-platform system automation

like image 102
vway Avatar answered Nov 07 '22 20:11

vway


ncurses bind - is the most lightweight solution I've found, all the others are parts of graphic or gaming engines

like image 42
snuk182 Avatar answered Nov 07 '22 22:11

snuk182


There are lots of ways to tackle this.

The project that appears closest to what you describe is "ui"

The next level up would be to use one of the go bindings that calls SDL, which might be easier.

Higher up the stack would be a toolkit like GTK, QT, FLTK, (or even X11 as BurntSushi5 mentioned, but I wouldn't recommend it.) Just search github for the toolkit and select by language.

like image 2
BraveNewCurrency Avatar answered Nov 07 '22 22:11

BraveNewCurrency