控制鼠标和键盘的 Golang 代码?

huangapple go评论105阅读模式
英文:

Control the mouse and keyboard Golang?

问题

如何在操作系统/X11级别上控制鼠标的位置、触发键盘事件?这类似于Java中的Robot类的功能。

我理解可能没有跨平台的解决方案,但是在Windows、Linux和Mac上如何实现呢?

英文:

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?

答案1

得分: 15

请查看 robotgo,这是一个用于 Golang 的原生跨平台系统自动化库。

英文:

Please see robotgo, Golang Native cross-platform system automation

答案2

得分: 2

有很多方法可以解决这个问题。

最接近你描述的项目是"ui"。

更高级的方法是使用调用SDLGo绑定库,这可能更容易一些。

再高级一点的方法是使用像GTK、QT、FLTK这样的工具包(或者像BurntSushi5提到的X11,但我不推荐这样做)。只需在GitHub上搜索相应的工具包,并按语言进行选择。

英文:

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.

答案3

得分: 2

ncurses bind - 是我找到的最轻量级的解决方案,其他的都是图形或游戏引擎的一部分。

英文:

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

huangapple
  • 本文由 发表于 2014年10月19日 09:00:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/26446184.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定