mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-01 14:43:55 +00:00
Update README.md
This commit is contained in:
parent
76abeff3ff
commit
427d2b4d61
85
README.md
85
README.md
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
RobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x86-amd64.
|
RobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x86-amd64.
|
||||||
|
|
||||||
[Chinese Simplified](https://github.com/go-vgo/robotgo/blob/master/README_zh.md)
|
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
- [Docs](#docs)
|
- [Docs](#docs)
|
||||||
- [Binding](#binding)
|
- [Binding](#binding)
|
||||||
@ -37,9 +35,7 @@ RobotGo supports Mac, Windows, and Linux(X11); and robotgo supports arm64 and x8
|
|||||||
|
|
||||||
## Docs
|
## Docs
|
||||||
- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>
|
- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>
|
||||||
|
|
||||||
- [API Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (Deprecated, no updated)
|
- [API Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (Deprecated, no updated)
|
||||||
- [Chinese Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md) (Deprecated, no updated)
|
|
||||||
|
|
||||||
## Binding:
|
## Binding:
|
||||||
[ADB](https://github.com/vcaesar/adb), packaging android adb API.
|
[ADB](https://github.com/vcaesar/adb), packaging android adb API.
|
||||||
@ -70,17 +66,15 @@ xcode-select --install
|
|||||||
[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (Use recommended)
|
[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (Use recommended)
|
||||||
|
|
||||||
```
|
```
|
||||||
Or the other GCC (But you should compile the "libpng" with yourself.
|
Or the other GCC (But you should compile the "libpng" with yourself when use the bitmap.)
|
||||||
Or you can removed the bitmap.go.
|
|
||||||
|
|
||||||
In the plans, the bitmap.go will moves to the bitmap dir, but break the API. )
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### For everything else:
|
#### For everything else:
|
||||||
|
|
||||||
```
|
```
|
||||||
GCC,
|
GCC
|
||||||
libpng (bitmap)
|
|
||||||
|
libpng (Just used by bitmap)
|
||||||
|
|
||||||
X11 with the XTest extension (also known as the Xtst library)
|
X11 with the XTest extension (also known as the Xtst library)
|
||||||
|
|
||||||
@ -99,20 +93,31 @@ xsel xclip
|
|||||||
# gcc
|
# gcc
|
||||||
sudo apt install gcc libc6-dev
|
sudo apt install gcc libc6-dev
|
||||||
|
|
||||||
sudo apt install libx11-dev xorg-dev libxtst-dev libpng++-dev
|
# x11
|
||||||
|
sudo apt install libx11-dev xorg-dev libxtst-dev
|
||||||
|
|
||||||
|
# Bitmap
|
||||||
|
sudo apt install libpng++-dev
|
||||||
|
|
||||||
|
# Hook
|
||||||
sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
|
sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev
|
||||||
|
|
||||||
|
# Clipboard
|
||||||
sudo apt install xsel xclip
|
sudo apt install xsel xclip
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Fedora:
|
##### Fedora:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
sudo dnf install libXtst-devel libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel
|
sudo dnf install libXtst-devel
|
||||||
|
|
||||||
|
# Bitmap
|
||||||
sudo dnf install libpng-devel
|
sudo dnf install libpng-devel
|
||||||
|
|
||||||
|
# Hook
|
||||||
|
sudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel
|
||||||
|
|
||||||
|
# Clipboard
|
||||||
sudo dnf install xsel xclip
|
sudo dnf install xsel xclip
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -241,10 +246,21 @@ func main() {
|
|||||||
|
|
||||||
bit := robotgo.CaptureScreen(10, 10, 30, 30)
|
bit := robotgo.CaptureScreen(10, 10, 30, 30)
|
||||||
defer robotgo.FreeBitmap(bit)
|
defer robotgo.FreeBitmap(bit)
|
||||||
robotgo.SaveBitmap(bit, "test_1.png")
|
|
||||||
|
|
||||||
img := robotgo.ToImage(bit)
|
img := robotgo.ToImage(bit)
|
||||||
imgo.Save("test.png", img)
|
imgo.Save("test.png", img)
|
||||||
|
|
||||||
|
num := robotgo.DisplaysNum()
|
||||||
|
for i := 0; i < num; i++ {
|
||||||
|
robotgo.DisplayID = i
|
||||||
|
img1 := robotgo.CaptureImg()
|
||||||
|
path1 := "save_" + strconv.Itoa(i)
|
||||||
|
robotgo.Save(img1, path1+".png")
|
||||||
|
robotgo.SaveJpeg(img1, path1+".jpeg", 50)
|
||||||
|
|
||||||
|
img2 := robotgo.CaptureImg(10, 10, 20, 20)
|
||||||
|
robotgo.Save(img2, "test_"+strconv.Itoa(i)+".png")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -257,30 +273,31 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
|
"github.com/vcaesar/bitmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
bitmap := robotgo.CaptureScreen(10, 20, 30, 40)
|
bit := robotgo.CaptureScreen(10, 20, 30, 40)
|
||||||
// use `defer robotgo.FreeBitmap(bit)` to free the bitmap
|
// use `defer robotgo.FreeBitmap(bit)` to free the bitmap
|
||||||
defer robotgo.FreeBitmap(bitmap)
|
defer robotgo.FreeBitmap(bit)
|
||||||
|
|
||||||
fmt.Println("bitmap...", bitmap)
|
fmt.Println("bitmap...", bit)
|
||||||
img := robotgo.ToImage(bitmap)
|
img := robotgo.ToImage(bit)
|
||||||
robotgo.SavePng(img, "test_1.png")
|
// robotgo.SavePng(img, "test_1.png")
|
||||||
|
robotgo.Save(img, "test_1.png")
|
||||||
|
|
||||||
bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
|
bit2 := robotgo.ToCBitmap(robotgo.ImgToBitmap(img))
|
||||||
fx, fy := robotgo.FindBitmap(bit2)
|
fx, fy := bitmap.Find(bit2)
|
||||||
fmt.Println("FindBitmap------ ", fx, fy)
|
fmt.Println("FindBitmap------ ", fx, fy)
|
||||||
robotgo.Move(fx, fy)
|
robotgo.Move(fx, fy)
|
||||||
|
|
||||||
arr := robotgo.FindAllBitmap(bit2)
|
arr := bitmap.FindAll(bit2)
|
||||||
fmt.Println("Find all bitmap: ", arr)
|
fmt.Println("Find all bitmap: ", arr)
|
||||||
robotgo.SaveBitmap(bitmap, "test.png")
|
|
||||||
|
|
||||||
fx, fy = robotgo.FindBitmap(bitmap)
|
fx, fy = bitmap.Find(bit)
|
||||||
fmt.Println("FindBitmap------ ", fx, fy)
|
fmt.Println("FindBitmap------ ", fx, fy)
|
||||||
|
|
||||||
robotgo.SaveBitmap(bitmap, "test.png")
|
bitmap.Save(bit, "test.png")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -354,7 +371,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/go-vgo/robotgo"
|
// "github.com/go-vgo/robotgo"
|
||||||
hook "github.com/robotn/gohook"
|
hook "github.com/robotn/gohook"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -366,18 +383,18 @@ func main() {
|
|||||||
|
|
||||||
func add() {
|
func add() {
|
||||||
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
|
fmt.Println("--- Please press ctrl + shift + q to stop hook ---")
|
||||||
robotgo.EventHook(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
|
hook.Register(hook.KeyDown, []string{"q", "ctrl", "shift"}, func(e hook.Event) {
|
||||||
fmt.Println("ctrl-shift-q")
|
fmt.Println("ctrl-shift-q")
|
||||||
robotgo.EventEnd()
|
hook.End()
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Println("--- Please press w---")
|
fmt.Println("--- Please press w---")
|
||||||
robotgo.EventHook(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
hook.Register(hook.KeyDown, []string{"w"}, func(e hook.Event) {
|
||||||
fmt.Println("w")
|
fmt.Println("w")
|
||||||
})
|
})
|
||||||
|
|
||||||
s := robotgo.EventStart()
|
s := hook.Start()
|
||||||
<-robotgo.EventProcess(s)
|
<-hook.Process(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func low() {
|
func low() {
|
||||||
@ -390,17 +407,17 @@ func low() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func event() {
|
func event() {
|
||||||
ok := robotgo.AddEvents("q", "ctrl", "shift")
|
ok := hook.AddEvents("q", "ctrl", "shift")
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Println("add events...")
|
fmt.Println("add events...")
|
||||||
}
|
}
|
||||||
|
|
||||||
keve := robotgo.AddEvent("k")
|
keve := hook.AddEvent("k")
|
||||||
if keve {
|
if keve {
|
||||||
fmt.Println("you press... ", "k")
|
fmt.Println("you press... ", "k")
|
||||||
}
|
}
|
||||||
|
|
||||||
mleft := robotgo.AddEvent("mleft")
|
mleft := hook.AddEvent("mleft")
|
||||||
if mleft {
|
if mleft {
|
||||||
fmt.Println("you press... ", "mouse left button")
|
fmt.Println("you press... ", "mouse left button")
|
||||||
}
|
}
|
||||||
@ -439,7 +456,7 @@ func main() {
|
|||||||
robotgo.Kill(100)
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
abool := robotgo.ShowAlert("test", "robotgo")
|
abool := robotgo.Alert("test", "robotgo")
|
||||||
if abool {
|
if abool {
|
||||||
fmt.Println("ok@@@ ", "ok")
|
fmt.Println("ok@@@ ", "ok")
|
||||||
}
|
}
|
||||||
@ -460,7 +477,7 @@ go build main.go
|
|||||||
|
|
||||||
#### Other to windows
|
#### Other to windows
|
||||||
|
|
||||||
Install Requirements (Ubuntu):
|
Install Requirements (Ubuntu, Just used by bitmap.):
|
||||||
```bash
|
```bash
|
||||||
sudo apt install gcc-multilib
|
sudo apt install gcc-multilib
|
||||||
sudo apt install gcc-mingw-w64
|
sudo apt install gcc-mingw-w64
|
||||||
|
@ -15,7 +15,7 @@ RobotGo 支持 Mac, Windows, and Linux(X11).
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
提 Issues 请到 [Github](https://github.com/go-vgo/robotgo), 便于统一管理和即时更新
|
提 Issues 请到 [Github](https://github.com/go-vgo/robotgo), 便于统一管理和即时更新; `REDAME_zh.md 已废弃, 不再更新`
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
- [Docs](#docs)
|
- [Docs](#docs)
|
||||||
@ -34,8 +34,8 @@ RobotGo 支持 Mac, Windows, and Linux(X11).
|
|||||||
## Docs
|
## Docs
|
||||||
- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>
|
- [GoDoc](https://godoc.org/github.com/go-vgo/robotgo) <br>
|
||||||
|
|
||||||
- [中文文档](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md) (弃用)
|
<!-- - [中文文档](https://github.com/go-vgo/robotgo/blob/master/docs/doc_zh.md) (弃用)
|
||||||
- [English Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (弃用)
|
- [English Docs](https://github.com/go-vgo/robotgo/blob/master/docs/doc.md) (弃用) -->
|
||||||
|
|
||||||
## Binding:
|
## Binding:
|
||||||
|
|
||||||
@ -430,7 +430,7 @@ func main() {
|
|||||||
robotgo.Kill(100)
|
robotgo.Kill(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
abool := robotgo.ShowAlert("test", "robotgo")
|
abool := robotgo.Alert("test", "robotgo")
|
||||||
if abool {
|
if abool {
|
||||||
fmt.Println("ok@@@ ", "ok")
|
fmt.Println("ok@@@ ", "ok")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user