Compare commits

...

4 Commits

Author SHA1 Message Date
Blink-A
73bfed5bd4
Merge be5a13d7b3 into 47abfac5ee 2025-04-15 04:17:52 +00:00
Evans
47abfac5ee
Merge pull request #716 from go-vgo/bitmap-pr
Some checks failed
Go / test (macOS-latest) (push) Has been cancelled
Go / test (windows-latest) (push) Has been cancelled
Fixed: fixed windows Scale #713 and Update readme.md
2025-04-11 14:37:12 -07:00
vcaesar
df0731c4df Fixed: fixed windows Scale #713 and Update readme.md
Some checks failed
Go / test (macOS-latest) (push) Has been cancelled
Go / test (windows-latest) (push) Has been cancelled
2025-04-11 14:34:15 -07:00
Blink-A
be5a13d7b3
Update screen_c.h 2024-08-18 16:34:02 +08:00
3 changed files with 42 additions and 9 deletions

View File

@ -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")

View File

@ -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)
}

View File

@ -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),