mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-17 05:23:56 +00:00
Compare commits
4 Commits
8ac68def76
...
73bfed5bd4
Author | SHA1 | Date | |
---|---|---|---|
![]() |
73bfed5bd4 | ||
![]() |
47abfac5ee | ||
![]() |
df0731c4df | ||
![]() |
be5a13d7b3 |
24
README.md
24
README.md
@ -61,6 +61,9 @@ GCC
|
||||
```
|
||||
|
||||
#### For MacOS:
|
||||
```
|
||||
brew install go
|
||||
```
|
||||
|
||||
Xcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277))
|
||||
|
||||
@ -69,8 +72,15 @@ xcode-select --install
|
||||
```
|
||||
|
||||
#### For Windows:
|
||||
```
|
||||
winget install Golang.go
|
||||
```
|
||||
|
||||
[MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (Use recommended) or others Mingw [llvm-mingw](https://github.com/mstorsjo/llvm-mingw);
|
||||
```
|
||||
winget install MartinStorsjo.LLVM-MinGW.UCRT
|
||||
```
|
||||
|
||||
Or [MinGW-w64](https://sourceforge.net/projects/mingw-w64/files) (Use recommended) or others Mingw [llvm-mingw](https://github.com/mstorsjo/llvm-mingw);
|
||||
|
||||
Download the Mingw, then set system environment variables `C:\mingw64\bin` to the Path.
|
||||
[Set environment variables to run GCC from command line](https://www.youtube.com/results?search_query=Set+environment+variables+to+run+GCC+from+command+line).
|
||||
@ -96,6 +106,9 @@ X11 with the XTest extension (the Xtst library)
|
||||
##### Ubuntu:
|
||||
|
||||
```yml
|
||||
# sudo apt install golang
|
||||
sudo snap install go --classic
|
||||
|
||||
# gcc
|
||||
sudo apt install gcc libc6-dev
|
||||
|
||||
@ -165,11 +178,18 @@ Note go1.10.x C file compilation cache problem, [golang #24355](https://github.c
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-vgo/robotgo"
|
||||
)
|
||||
|
||||
func main() {
|
||||
robotgo.MouseSleep = 100
|
||||
robotgo.MouseSleep = 300
|
||||
|
||||
robotgo.Move(100, 100)
|
||||
fmt.Println(robotgo.Location())
|
||||
robotgo.Move(100, -200) // multi screen supported
|
||||
robotgo.MoveSmooth(120, -150)
|
||||
fmt.Println(robotgo.Location())
|
||||
|
||||
robotgo.ScrollDir(10, "up")
|
||||
robotgo.ScrollDir(20, "right")
|
||||
|
@ -506,7 +506,7 @@ func CheckMouse(btn string) C.MMMouseButton {
|
||||
|
||||
// MoveScale calculate the os scale factor x, y
|
||||
func MoveScale(x, y int, displayId ...int) (int, int) {
|
||||
if Scale && runtime.GOOS == "windows" {
|
||||
if Scale || runtime.GOOS == "windows" {
|
||||
f := ScaleF()
|
||||
x, y = Scaled1(x, f), Scaled1(y, f)
|
||||
}
|
||||
@ -630,7 +630,7 @@ func Location() (int, int) {
|
||||
x := int(pos.x)
|
||||
y := int(pos.y)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
if Scale || runtime.GOOS == "windows" {
|
||||
f := ScaleF()
|
||||
x, y = Scaled0(x, f), Scaled0(y, f)
|
||||
}
|
||||
|
@ -76,12 +76,25 @@ MMSizeInt32 getMainDisplaySize(void) {
|
||||
CGSize size = displayRect.size;
|
||||
return MMSizeInt32Make((int32_t)size.width, (int32_t)size.height);
|
||||
#elif defined(USE_X11)
|
||||
Display *display = XGetMainDisplay();
|
||||
const int screen = DefaultScreen(display);
|
||||
// Display *display = XGetMainDisplay();
|
||||
// const int screen = DefaultScreen(display);
|
||||
|
||||
return MMSizeInt32Make(
|
||||
// return MMSizeInt32Make(
|
||||
// (int32_t)DisplayWidth(display, screen),
|
||||
// (int32_t)DisplayHeight(display, screen));
|
||||
Display *display = XOpenDisplay(NULL);
|
||||
if (display == NULL) {
|
||||
return MMSizeInt32Make(0, 0); // Return an invalid size if unable to open display
|
||||
}
|
||||
|
||||
const int screen = DefaultScreen(display);
|
||||
MMSizeInt32 resolution = MMSizeInt32Make(
|
||||
(int32_t)DisplayWidth(display, screen),
|
||||
(int32_t)DisplayHeight(display, screen));
|
||||
(int32_t)DisplayHeight(display, screen)
|
||||
);
|
||||
|
||||
XCloseDisplay(display);
|
||||
return resolution;
|
||||
#elif defined(IS_WINDOWS)
|
||||
return MMSizeInt32Make(
|
||||
(int32_t)GetSystemMetrics(SM_CXSCREEN),
|
||||
|
Loading…
Reference in New Issue
Block a user