mirror of
https://github.com/go-vgo/robotgo.git
synced 2025-06-17 13:33:55 +00:00
Compare commits
7 Commits
8894579f4d
...
8f2fc3a286
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8f2fc3a286 | ||
![]() |
57b5e5bca2 | ||
![]() |
8031f7f526 | ||
![]() |
36bc85ad19 | ||
![]() |
5fc2bd4c73 | ||
![]() |
47abfac5ee | ||
![]() |
df0731c4df |
@ -1,5 +1,5 @@
|
|||||||
# FROM golang:1.10.1
|
# FROM golang:1.10.1
|
||||||
FROM golang:1.23.2-stretch AS build
|
FROM golang:1.24.2-stretch AS build
|
||||||
# FROM govgo/go:1.11.1
|
# FROM govgo/go:1.11.1
|
||||||
|
|
||||||
RUN apt update && apt install -y --no-install-recommends \
|
RUN apt update && apt install -y --no-install-recommends \
|
||||||
|
24
README.md
24
README.md
@ -61,6 +61,9 @@ GCC
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### For MacOS:
|
#### For MacOS:
|
||||||
|
```
|
||||||
|
brew install go
|
||||||
|
```
|
||||||
|
|
||||||
Xcode Command Line Tools (And Privacy setting: [#277](https://github.com/go-vgo/robotgo/issues/277))
|
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:
|
#### 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.
|
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).
|
[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:
|
##### Ubuntu:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
# sudo apt install golang
|
||||||
|
sudo snap install go --classic
|
||||||
|
|
||||||
# gcc
|
# gcc
|
||||||
sudo apt install gcc libc6-dev
|
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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/go-vgo/robotgo"
|
"github.com/go-vgo/robotgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
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(10, "up")
|
||||||
robotgo.ScrollDir(20, "right")
|
robotgo.ScrollDir(20, "right")
|
||||||
|
2
go.mod
2
go.mod
@ -23,13 +23,13 @@ require (
|
|||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
github.com/jezek/xgb v1.1.1 // indirect
|
github.com/jezek/xgb v1.1.1 // indirect
|
||||||
github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c
|
|
||||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
|
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
|
||||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
|
github.com/lxn/win v0.0.0-20210218163916-a377121e959e // indirect
|
||||||
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
|
||||||
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
|
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
github.com/tklauser/go-sysconf v0.3.14 // indirect
|
||||||
github.com/tklauser/numcpus v0.9.0 // indirect
|
github.com/tklauser/numcpus v0.9.0 // indirect
|
||||||
|
github.com/vcaesar/screenshot v0.11.0
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||||
golang.org/x/exp v0.0.0-20250215185904-eff6e970281f // indirect
|
golang.org/x/exp v0.0.0-20250215185904-eff6e970281f // indirect
|
||||||
golang.org/x/image v0.24.0 // indirect
|
golang.org/x/image v0.24.0 // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -17,8 +17,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
|||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
|
github.com/jezek/xgb v1.1.1 h1:bE/r8ZZtSv7l9gk6nU0mYx51aXrvnyb44892TwSaqS4=
|
||||||
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
github.com/jezek/xgb v1.1.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
|
||||||
github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c h1:1IlzDla/ZATV/FsRn1ETf7ir91PHS2mrd4VMunEtd9k=
|
|
||||||
github.com/kbinani/screenshot v0.0.0-20250118074034-a3924b7bbc8c/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ=
|
|
||||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
|
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
|
||||||
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
|
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
|
||||||
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
|
github.com/lxn/win v0.0.0-20210218163916-a377121e959e h1:H+t6A/QJMbhCSEH5rAuRxh+CtW96g0Or0Fxa9IKr4uc=
|
||||||
@ -56,6 +54,8 @@ github.com/vcaesar/imgo v0.40.2 h1:5GWScRLdBCMtO1v2I1bs+ZmDLZFINxYSMZ+mtUw5qPM=
|
|||||||
github.com/vcaesar/imgo v0.40.2/go.mod h1:MVCl+FxHI2gTgmiHoi0n5xNCbYcfv9SVtdEOUC92+eo=
|
github.com/vcaesar/imgo v0.40.2/go.mod h1:MVCl+FxHI2gTgmiHoi0n5xNCbYcfv9SVtdEOUC92+eo=
|
||||||
github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw=
|
github.com/vcaesar/keycode v0.10.1 h1:0DesGmMAPWpYTCYddOFiCMKCDKgNnwiQa2QXindVUHw=
|
||||||
github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
|
github.com/vcaesar/keycode v0.10.1/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
|
||||||
|
github.com/vcaesar/screenshot v0.11.0 h1:ULNC6tTye6oNzleuqskzTMSjH8xonmuUIYfYjlYAM3g=
|
||||||
|
github.com/vcaesar/screenshot v0.11.0/go.mod h1:wixTD3T2Sz3Oi6Hfl33CMcBffd3mLbT7WavfK2UrQcI=
|
||||||
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
|
github.com/vcaesar/tt v0.20.1 h1:D/jUeeVCNbq3ad8M7hhtB3J9x5RZ6I1n1eZ0BJp7M+4=
|
||||||
github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU=
|
github.com/vcaesar/tt v0.20.1/go.mod h1:cH2+AwGAJm19Wa6xvEa+0r+sXDJBT0QgNQey6mwqLeU=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
|
10
robotgo.go
10
robotgo.go
@ -31,10 +31,10 @@ package robotgo
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
|
#cgo darwin CFLAGS: -x objective-c -Wno-deprecated-declarations
|
||||||
#cgo darwin LDFLAGS: -framework Cocoa -framework OpenGL -framework IOKit
|
#cgo darwin LDFLAGS: -framework Cocoa -framework CoreFoundation -framework IOKit
|
||||||
#cgo darwin LDFLAGS: -framework Carbon -framework CoreFoundation
|
#cgo darwin LDFLAGS: -framework Carbon -framework OpenGL
|
||||||
//
|
//
|
||||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
|
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 140400
|
||||||
#cgo darwin LDFLAGS: -framework ScreenCaptureKit
|
#cgo darwin LDFLAGS: -framework ScreenCaptureKit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ func CheckMouse(btn string) C.MMMouseButton {
|
|||||||
|
|
||||||
// MoveScale calculate the os scale factor x, y
|
// MoveScale calculate the os scale factor x, y
|
||||||
func MoveScale(x, y int, displayId ...int) (int, int) {
|
func MoveScale(x, y int, displayId ...int) (int, int) {
|
||||||
if Scale && runtime.GOOS == "windows" {
|
if Scale || runtime.GOOS == "windows" {
|
||||||
f := ScaleF()
|
f := ScaleF()
|
||||||
x, y = Scaled1(x, f), Scaled1(y, f)
|
x, y = Scaled1(x, f), Scaled1(y, f)
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ func Location() (int, int) {
|
|||||||
x := int(pos.x)
|
x := int(pos.x)
|
||||||
y := int(pos.y)
|
y := int(pos.y)
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if Scale || runtime.GOOS == "windows" {
|
||||||
f := ScaleF()
|
f := ScaleF()
|
||||||
x, y = Scaled0(x, f), Scaled0(y, f)
|
x, y = Scaled0(x, f), Scaled0(y, f)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ package robotgo
|
|||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
"github.com/kbinani/screenshot"
|
// "github.com/kbinani/screenshot"
|
||||||
|
"github.com/vcaesar/screenshot"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDisplayBounds gets the display screen bounds
|
// GetDisplayBounds gets the display screen bounds
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "screen_c.h"
|
#include "screen_c.h"
|
||||||
|
|
||||||
#if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
|
#if defined(IS_MACOSX) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 140400
|
||||||
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
|
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
|
||||||
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||||
__block CGImageRef image1 = nil;
|
__block CGImageRef image1 = nil;
|
||||||
@ -76,7 +76,7 @@ MMBitmapRef copyMMBitmapFromDisplayInRect(MMRectInt32 rect, int32_t display_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MMPointInt32 o = rect.origin; MMSizeInt32 s = rect.size;
|
MMPointInt32 o = rect.origin; MMSizeInt32 s = rect.size;
|
||||||
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > MAC_OS_VERSION_14_4
|
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 140400
|
||||||
CGColorSpaceRef color = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
CGColorSpaceRef color = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
|
||||||
CGImageRef image = capture15(displayID, CGRectMake(o.x, o.y, s.w, s.h), color);
|
CGImageRef image = capture15(displayID, CGRectMake(o.x, o.y, s.w, s.h), color);
|
||||||
CGColorSpaceRelease(color);
|
CGColorSpaceRelease(color);
|
||||||
|
Loading…
Reference in New Issue
Block a user