Compare commits

...

16 Commits

Author SHA1 Message Date
Ed Lewis
8a87c48900
Merge 401c6cba6c into 471f7ba05f 2024-10-11 20:09:56 +08:00
Evans
471f7ba05f
Merge pull request #695 from go-vgo/bitmap-pr
Some checks failed
Go / test (macOS-latest) (push) Has been cancelled
Go / test (windows-latest) (push) Has been cancelled
Update: update go mod
2024-10-07 14:17:46 -07:00
vcaesar
a84a195c4c Update: update go mod
Some checks failed
Go / test (macOS-latest) (push) Has been cancelled
Go / test (windows-latest) (push) Has been cancelled
2024-10-07 14:15:17 -07:00
Evans
c8df366f89
Merge pull request #694 from go-vgo/bitmap-pr
Update: update readme.md
2024-10-07 14:10:09 -07:00
vcaesar
70f811ce53 Update: update readme.md 2024-10-07 14:09:01 -07:00
Evans
ecc260ea31
Merge pull request #693 from go-vgo/bitmap-pr
Update: update screen capture code and examples
2024-10-07 14:00:37 -07:00
vcaesar
78d01703b8 Update: update examples and test code, README.md 2024-10-07 13:56:46 -07:00
vcaesar
47cde13dab Update: update screen capture code and examples 2024-10-07 13:45:03 -07:00
aohanhongzhi
8db59aac2d
capture error (#663)
* capture error

* aohanhongzhi

* Update go.mod

---------

Co-authored-by: Evans <vzvway@gmail.com>
2024-10-07 13:29:39 -07:00
Evans
217d6cf1f1
Merge pull request #692 from go-vgo/bitmap-pr
Some checks are pending
Go / test (macOS-latest) (push) Waiting to run
Go / test (windows-latest) (push) Waiting to run
Fixed: default use high capture resolution in macos15
2024-10-06 18:12:41 -07:00
vcaesar
75fd24ea0a Fixed: Fixed x11 build
Some checks are pending
Go / test (macOS-latest) (push) Waiting to run
Go / test (windows-latest) (push) Waiting to run
2024-10-06 18:11:23 -07:00
vcaesar
bed6776ca2 Fixed: default use high capture resolution in macos15 2024-10-06 18:04:17 -07:00
Evans
1923d7bb48
Merge pull request #691 from go-vgo/bitmap-pr
Update: move scale to screen and rename pub mdata
2024-10-06 17:54:40 -07:00
vcaesar
ead43d062e Fixed: fix x11 build 2024-10-06 17:51:51 -07:00
vcaesar
3258566802 Update: move scale to screen and rename pub mdata 2024-10-06 17:40:34 -07:00
Ed Lewis
401c6cba6c Update Fedora requirements in README
Updated readme for Fedora requirements as the package xorg-x11-xkb-utils-devel seems to have moved to xkbcomp-devel in later Fedora versions
2024-01-03 10:36:51 +00:00
15 changed files with 173 additions and 154 deletions

View File

@ -1,5 +1,5 @@
# FROM golang:1.10.1 # FROM golang:1.10.1
FROM golang:1.22.3-stretch AS build FROM golang:1.23.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 \

View File

@ -128,7 +128,7 @@ sudo dnf install xsel xclip
sudo dnf install libpng-devel sudo dnf install libpng-devel
# GoHook # GoHook
sudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xorg-x11-xkb-utils-devel sudo dnf install libxkbcommon-devel libxkbcommon-x11-devel xkbcomp-devel
``` ```
@ -268,13 +268,18 @@ func main() {
num := robotgo.DisplaysNum() num := robotgo.DisplaysNum()
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
robotgo.DisplayID = i robotgo.DisplayID = i
img1 := robotgo.CaptureImg() img1, _ := robotgo.CaptureImg()
path1 := "save_" + strconv.Itoa(i) path1 := "save_" + strconv.Itoa(i)
robotgo.Save(img1, path1+".png") robotgo.Save(img1, path1+".png")
robotgo.SaveJpeg(img1, path1+".jpeg", 50) robotgo.SaveJpeg(img1, path1+".jpeg", 50)
img2 := robotgo.CaptureImg(10, 10, 20, 20) img2, _ := robotgo.CaptureImg(10, 10, 20, 20)
robotgo.Save(img2, "test_"+strconv.Itoa(i)+".png") robotgo.Save(img2, "test_"+strconv.Itoa(i)+".png")
x, y, w, h := robotgo.GetDisplayBounds(i)
img3, err := robotgo.CaptureImg(x, y, w, h)
fmt.Println("Capture error: ", err)
robotgo.Save(img3, path1+"_1.png")
} }
} }
``` ```
@ -354,8 +359,8 @@ func opencv() {
// bit1 := robotgo.CaptureScreen(10, 10, 30, 30) // bit1 := robotgo.CaptureScreen(10, 10, 30, 30)
// img1 := robotgo.ToImage(bit1) // img1 := robotgo.ToImage(bit1)
// defer robotgo.FreeBitmapArr(bit0, bit1) // defer robotgo.FreeBitmapArr(bit0, bit1)
img := robotgo.CaptureImg() img, _ := robotgo.CaptureImg()
img1 := robotgo.CaptureImg(10, 10, 30, 30) img1, _ := robotgo.CaptureImg(10, 10, 30, 30)
fmt.Print("gcv find image: ") fmt.Print("gcv find image: ")
fmt.Println(gcv.FindImg(img1, img)) fmt.Println(gcv.FindImg(img1, img))

View File

@ -29,23 +29,29 @@ func bitmap() {
gbitMap := robotgo.CaptureGo() gbitMap := robotgo.CaptureGo()
fmt.Println("Go CaptureScreen...", gbitMap.Width) fmt.Println("Go CaptureScreen...", gbitMap.Width)
// fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel) // fmt.Println("...", gbitmap.Width, gbitmap.BytesPerPixel)
// robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100) robotgo.SaveCapture("saveCapture.png", 10, 20, 100, 100)
img := robotgo.CaptureImg() img, err := robotgo.CaptureImg()
fmt.Println("error: ", err)
robotgo.Save(img, "save.png") robotgo.Save(img, "save.png")
num := robotgo.DisplaysNum() num := robotgo.DisplaysNum()
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
robotgo.DisplayID = i robotgo.DisplayID = i
img1 := robotgo.CaptureImg() img1, _ := robotgo.CaptureImg()
path1 := "save_" + strconv.Itoa(i) path1 := "save_" + strconv.Itoa(i)
robotgo.Save(img1, path1+".png") robotgo.Save(img1, path1+".png")
robotgo.SaveJpeg(img1, path1+".jpeg", 50) robotgo.SaveJpeg(img1, path1+".jpeg", 50)
img2 := robotgo.CaptureImg(10, 10, 20, 20) img2, _ := robotgo.CaptureImg(10, 10, 20, 20)
path2 := "test_" + strconv.Itoa(i) path2 := "test_" + strconv.Itoa(i)
robotgo.Save(img2, path2+".png") robotgo.Save(img2, path2+".png")
robotgo.SaveJpeg(img2, path2+".jpeg", 50) robotgo.SaveJpeg(img2, path2+".jpeg", 50)
x, y, w, h := robotgo.GetDisplayBounds(i)
img3, err := robotgo.CaptureImg(x, y, w, h)
fmt.Println("Capture error: ", err)
robotgo.Save(img3, path2+"_1.png")
} }
} }

22
go.mod
View File

@ -1,15 +1,15 @@
module github.com/go-vgo/robotgo module github.com/go-vgo/robotgo
go 1.22 go 1.22.0
toolchain go1.23.0 toolchain go1.23.2
require ( require (
github.com/otiai10/gosseract/v2 v2.4.1 github.com/otiai10/gosseract/v2 v2.4.1
// github.com/robotn/gohook v0.31.3 // github.com/robotn/gohook v0.31.3
github.com/robotn/xgb v0.10.0 github.com/robotn/xgb v0.10.0
github.com/robotn/xgbutil v0.10.0 github.com/robotn/xgbutil v0.10.0
github.com/tailscale/win v0.0.0-20240830200727-2d6766fe9b74 github.com/tailscale/win v0.0.0-20240926211701-28f7e73c7afb
github.com/vcaesar/gops v0.40.0 github.com/vcaesar/gops v0.40.0
github.com/vcaesar/imgo v0.40.2 github.com/vcaesar/imgo v0.40.2
github.com/vcaesar/keycode v0.10.1 github.com/vcaesar/keycode v0.10.1
@ -18,22 +18,22 @@ require (
require ( require (
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect
github.com/gen2brain/shm v0.1.0 // indirect github.com/ebitengine/purego v0.8.0 // indirect
github.com/gen2brain/shm v0.1.1 // indirect
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-20240820160931-a8a2c5d0e191 github.com/kbinani/screenshot v0.0.0-20240820160931-a8a2c5d0e191
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7 // 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.24.8 // indirect github.com/shirou/gopsutil/v4 v4.24.9 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.8.0 // indirect github.com/tklauser/numcpus v0.9.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 // indirect
golang.org/x/image v0.20.0 // indirect golang.org/x/image v0.21.0 // indirect
golang.org/x/sys v0.25.0 // indirect golang.org/x/sys v0.26.0 // indirect
) )
// replace golang.org/x/sys => github.com/golang/sys v0.0.0-20190109145017-48ac38b7c8cb // replace golang.org/x/sys => github.com/golang/sys v0.0.0-20190109145017-48ac38b7c8cb

38
go.sum
View File

@ -4,8 +4,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e h1:L+XrFvD0vBIBm+Wf9sFN6aU395t7JROoai0qXZraA4U= github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e h1:L+XrFvD0vBIBm+Wf9sFN6aU395t7JROoai0qXZraA4U=
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e/go.mod h1:SUxUaAK/0UG5lYyZR1L1nC4AaYYvSSYTWQSH3FPcxKU= github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e/go.mod h1:SUxUaAK/0UG5lYyZR1L1nC4AaYYvSSYTWQSH3FPcxKU=
github.com/gen2brain/shm v0.1.0 h1:MwPeg+zJQXN0RM9o+HqaSFypNoNEcNpeoGp0BTSx2YY= github.com/ebitengine/purego v0.8.0 h1:JbqvnEzRvPpxhCJzJJ2y0RbiZ8nyjccVUrSM3q+GvvE=
github.com/gen2brain/shm v0.1.0/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA= github.com/ebitengine/purego v0.8.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/gen2brain/shm v0.1.1 h1:1cTVA5qcsUFixnDHl14TmRoxgfWEEZlTezpUj1vm5uQ=
github.com/gen2brain/shm v0.1.1/go.mod h1:UgIcVtvmOu+aCJpqJX7GOtiN7X2ct+TKLg4RTxwPIUA=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
@ -17,8 +19,8 @@ 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-20240820160931-a8a2c5d0e191 h1:5UHVWNX1qrIbNw7OpKbxe5bHkhHRk3xRKztMjERuCsU= github.com/kbinani/screenshot v0.0.0-20240820160931-a8a2c5d0e191 h1:5UHVWNX1qrIbNw7OpKbxe5bHkhHRk3xRKztMjERuCsU=
github.com/kbinani/screenshot v0.0.0-20240820160931-a8a2c5d0e191/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ= github.com/kbinani/screenshot v0.0.0-20240820160931-a8a2c5d0e191/go.mod h1:Pmpz2BLf55auQZ67u3rvyI2vAQvNetkK/4zYUmpauZQ=
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7 h1:5RK988zAqB3/AN3opGfRpoQgAVqr6/A5+qRTi67VUZY= github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7/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=
github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk= github.com/lxn/win v0.0.0-20210218163916-a377121e959e/go.mod h1:KxxjdtRkfNoYDCUP5ryK7XJJNTnpC8atvtmTheChOtk=
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ= github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
@ -36,22 +38,18 @@ github.com/robotn/xgb v0.10.0 h1:O3kFbIwtwZ3pgLbp1h5slCQ4OpY8BdwugJLrUe6GPIM=
github.com/robotn/xgb v0.10.0/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ= github.com/robotn/xgb v0.10.0/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw= github.com/robotn/xgbutil v0.10.0 h1:gvf7mGQqCWQ68aHRtCxgdewRk+/KAJui6l3MJQQRCKw=
github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU= github.com/robotn/xgbutil v0.10.0/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/shirou/gopsutil/v4 v4.24.8 h1:pVQjIenQkIhqO81mwTaXjTzOMT7d3TZkf43PlVFHENI= github.com/shirou/gopsutil/v4 v4.24.9 h1:KIV+/HaHD5ka5f570RZq+2SaeFsb/pq+fp2DGNWYoOI=
github.com/shirou/gopsutil/v4 v4.24.8/go.mod h1:wE0OrJtj4dG+hYkxqDH3QiBICdKSf04/npcvLLc/oRg= github.com/shirou/gopsutil/v4 v4.24.9/go.mod h1:3fkaHNeYsUFCGZ8+9vZVWtbyM1k2eRnlL+bWO8Bxa/Q=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tailscale/win v0.0.0-20240830200727-2d6766fe9b74 h1:a6itf7Z0Ahy5z5RVTkasDAbcOIJ/GwWRjkWVgaUhWuo= github.com/tailscale/win v0.0.0-20240926211701-28f7e73c7afb h1:5C+a9Lxq5GYIxsAF8JsMOlZ90+bOFSUQJ8J6XVk4vUM=
github.com/tailscale/win v0.0.0-20240830200727-2d6766fe9b74/go.mod h1:aMd4yDHLjbOuYP6fMxj1d9ACDQlSWwYztcpybGHCQc8= github.com/tailscale/win v0.0.0-20240926211701-28f7e73c7afb/go.mod h1:aMd4yDHLjbOuYP6fMxj1d9ACDQlSWwYztcpybGHCQc8=
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA= github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=
github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk= github.com/tc-hib/winres v0.2.1/go.mod h1:C/JaNhH3KBvhNKVbvdlDWkbMDO9H4fKKDaN7/07SSuk=
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo=
github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= github.com/tklauser/numcpus v0.9.0/go.mod h1:SN6Nq1O3VychhC1npsWostA+oW+VOQTxZrS604NSRyI=
github.com/vcaesar/gops v0.40.0 h1:I+1RCGiV+LkZJUYNzAd373xs0uM2UyeFdZBmow8HfCM= github.com/vcaesar/gops v0.40.0 h1:I+1RCGiV+LkZJUYNzAd373xs0uM2UyeFdZBmow8HfCM=
github.com/vcaesar/gops v0.40.0/go.mod h1:3u/USW7JovqUK6i13VOD3qWfvXXd2TIIKE4PYIv4TOM= github.com/vcaesar/gops v0.40.0/go.mod h1:3u/USW7JovqUK6i13VOD3qWfvXXd2TIIKE4PYIv4TOM=
github.com/vcaesar/imgo v0.40.2 h1:5GWScRLdBCMtO1v2I1bs+ZmDLZFINxYSMZ+mtUw5qPM= github.com/vcaesar/imgo v0.40.2 h1:5GWScRLdBCMtO1v2I1bs+ZmDLZFINxYSMZ+mtUw5qPM=
@ -62,15 +60,15 @@ 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=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 h1:1wqE9dj9NpSm04INVsJhhEUzhuDVjbcyKH91sVyPATw=
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/image v0.20.0 h1:7cVCUjQwfL18gyBJOmYvptfSHS8Fb3YUDtfLIZ7Nbpw= golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
golang.org/x/image v0.20.0/go.mod h1:0a88To4CYVBAHp5FXJm8o7QbUl37Vd85ply1vyD8auM= golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -50,6 +50,7 @@ package robotgo
import "C" import "C"
import ( import (
"errors"
"image" "image"
"runtime" "runtime"
"time" "time"
@ -365,12 +366,15 @@ func CaptureGo(args ...int) Bitmap {
return ToBitmap(bit) return ToBitmap(bit)
} }
// CaptureImg capture the screen and return image.Image // CaptureImg capture the screen and return image.Image, error
func CaptureImg(args ...int) image.Image { func CaptureImg(args ...int) (image.Image, error) {
bit := CaptureScreen(args...) bit := CaptureScreen(args...)
if bit == nil {
return nil, errors.New("Capture image not found.")
}
defer FreeBitmap(bit) defer FreeBitmap(bit)
return ToImage(bit) return ToImage(bit), nil
} }
// FreeBitmap free and dealloc the C bitmap // FreeBitmap free and dealloc the C bitmap

View File

@ -179,7 +179,8 @@ func TestImage(t *testing.T) {
err := SavePng(img, "robot_test.png") err := SavePng(img, "robot_test.png")
tt.Nil(t, err) tt.Nil(t, err)
img1 := CaptureImg(10, 10, 20, 20) img1, err := CaptureImg(10, 10, 20, 20)
tt.Nil(t, err)
e := Save(img1, "robot_img.jpeg", 50) e := Save(img1, "robot_img.jpeg", 50)
tt.Nil(t, e) tt.Nil(t, e)

View File

@ -30,7 +30,7 @@ func GetDisplayRect(i int) Rect {
Size{W: w, H: h}} Size{W: w, H: h}}
} }
// Capture capture the screenshot // Capture capture the screenshot, use the CaptureImg default
func Capture(args ...int) (*image.RGBA, error) { func Capture(args ...int) (*image.RGBA, error) {
displayId := 0 displayId := 0
if DisplayID != -1 { if DisplayID != -1 {
@ -53,7 +53,7 @@ func Capture(args ...int) (*image.RGBA, error) {
// SaveCapture capture screen and save the screenshot to image // SaveCapture capture screen and save the screenshot to image
func SaveCapture(path string, args ...int) error { func SaveCapture(path string, args ...int) error {
img, err := Capture(args...) img, err := CaptureImg(args...)
if err != nil { if err != nil {
return err return err
} }

View File

@ -12,7 +12,6 @@
#include "../base/pubs.h" #include "../base/pubs.h"
#include "../base/rgb.h" #include "../base/rgb.h"
#include "screengrab_c.h" #include "screengrab_c.h"
#include "screen_c.h"
#include <stdio.h> #include <stdio.h>
void padHex(MMRGBHex color, char* hex) { void padHex(MMRGBHex color, char* hex) {

View File

@ -4,9 +4,70 @@
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#elif defined(USE_X11) #elif defined(USE_X11)
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xresource.h>
// #include "../base/xdisplay_c.h" // #include "../base/xdisplay_c.h"
#endif #endif
intptr scaleX();
double sys_scale(int32_t display_id) {
#if defined(IS_MACOSX)
CGDirectDisplayID displayID = (CGDirectDisplayID) display_id;
if (displayID == -1) {
displayID = CGMainDisplayID();
}
CGDisplayModeRef modeRef = CGDisplayCopyDisplayMode(displayID);
double pixelWidth = CGDisplayModeGetPixelWidth(modeRef);
double targetWidth = CGDisplayModeGetWidth(modeRef);
return pixelWidth / targetWidth;
#elif defined(USE_X11)
Display *dpy = XOpenDisplay(NULL);
int scr = 0; /* Screen number */
double xres = ((((double) DisplayWidth(dpy, scr)) * 25.4) /
((double) DisplayWidthMM(dpy, scr)));
char *rms = XResourceManagerString(dpy);
if (rms) {
XrmDatabase db = XrmGetStringDatabase(rms);
if (db) {
XrmValue value;
char *type = NULL;
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value)) {
if (value.addr) {
xres = atof(value.addr);
}
}
XrmDestroyDatabase(db);
}
}
XCloseDisplay (dpy);
return xres / 96.0;
#elif defined(IS_WINDOWS)
double s = scaleX() / 96.0;
return s;
#endif
}
intptr scaleX(){
#if defined(IS_MACOSX)
return 0;
#elif defined(USE_X11)
return 0;
#elif defined(IS_WINDOWS)
// Get desktop dc
HDC desktopDc = GetDC(NULL);
// Get native resolution
intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX);
return horizontalDPI;
#endif
}
MMSizeInt32 getMainDisplaySize(void) { MMSizeInt32 getMainDisplaySize(void) {
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
CGDirectDisplayID displayID = CGMainDisplayID(); CGDirectDisplayID displayID = CGMainDisplayID();

View File

@ -13,6 +13,7 @@
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
#include <string.h> #include <string.h>
#endif #endif
#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__ > MAC_OS_VERSION_14_4
static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) { static CGImageRef capture15(CGDirectDisplayID id, CGRect diIntersectDisplayLocal, CGColorSpaceRef colorSpace) {
@ -39,9 +40,12 @@
SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]]; SCContentFilter* filter = [[SCContentFilter alloc] initWithDisplay:target excludingWindows:@[]];
SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init]; SCStreamConfiguration* config = [[SCStreamConfiguration alloc] init];
config.queueDepth = 5;
config.sourceRect = diIntersectDisplayLocal; config.sourceRect = diIntersectDisplayLocal;
config.width = diIntersectDisplayLocal.size.width; config.width = diIntersectDisplayLocal.size.width * sys_scale(id);
config.height = diIntersectDisplayLocal.size.height; config.height = diIntersectDisplayLocal.size.height * sys_scale(id);
config.scalesToFit = false;
config.captureResolution = 1;
[SCScreenshotManager captureImageWithFilter:filter [SCScreenshotManager captureImageWithFilter:filter
configuration:config configuration:config

View File

@ -55,11 +55,11 @@ uintptr get_handle(){
uintptr b_get_handle() { uintptr b_get_handle() {
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
return (uintptr)mData.CgID; return (uintptr)pub_mData.CgID;
#elif defined(USE_X11) #elif defined(USE_X11)
return (uintptr)mData.XWin; return (uintptr)pub_mData.XWin;
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
return (uintptr)mData.HWnd; return (uintptr)pub_mData.HWnd;
#endif #endif
} }

View File

@ -28,7 +28,7 @@ struct _MData{
}; };
typedef struct _MData MData; typedef struct _MData MData;
MData mData; MData pub_mData;
struct _Bounds { struct _Bounds {
int32_t X; // Top left X coordinate int32_t X; // Top left X coordinate

View File

@ -8,70 +8,11 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#if defined(USE_X11) // #if defined(USE_X11)
#include <X11/Xresource.h> // #include <X11/Xresource.h>
#endif // #endif
Bounds get_client(uintptr pid, int8_t isPid); Bounds get_client(uintptr pid, int8_t isPid);
intptr scaleX();
double sys_scale(int32_t display_id) {
#if defined(IS_MACOSX)
CGDirectDisplayID displayID = (CGDirectDisplayID) display_id;
if (displayID == -1) {
displayID = CGMainDisplayID();
}
CGDisplayModeRef modeRef = CGDisplayCopyDisplayMode(displayID);
double pixelWidth = CGDisplayModeGetPixelWidth(modeRef);
double targetWidth = CGDisplayModeGetWidth(modeRef);
return pixelWidth / targetWidth;
#elif defined(USE_X11)
Display *dpy = XOpenDisplay(NULL);
int scr = 0; /* Screen number */
double xres = ((((double) DisplayWidth(dpy, scr)) * 25.4) /
((double) DisplayWidthMM(dpy, scr)));
char *rms = XResourceManagerString(dpy);
if (rms) {
XrmDatabase db = XrmGetStringDatabase(rms);
if (db) {
XrmValue value;
char *type = NULL;
if (XrmGetResource(db, "Xft.dpi", "String", &type, &value)) {
if (value.addr) {
xres = atof(value.addr);
}
}
XrmDestroyDatabase(db);
}
}
XCloseDisplay (dpy);
return xres / 96.0;
#elif defined(IS_WINDOWS)
double s = scaleX() / 96.0;
return s;
#endif
}
intptr scaleX(){
#if defined(IS_MACOSX)
return 0;
#elif defined(USE_X11)
return 0;
#elif defined(IS_WINDOWS)
// Get desktop dc
HDC desktopDc = GetDC(NULL);
// Get native resolution
intptr horizontalDPI = GetDeviceCaps(desktopDc, LOGPIXELSX);
return horizontalDPI;
#endif
}
Bounds get_bounds(uintptr pid, int8_t isPid){ Bounds get_bounds(uintptr pid, int8_t isPid){
// Check if the window is valid // Check if the window is valid

View File

@ -24,8 +24,8 @@ uintptr initHandle = 0;
void initWindow(uintptr handle){ void initWindow(uintptr handle){
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
mData.CgID = 0; pub_mData.CgID = 0;
mData.AxID = 0; pub_mData.AxID = 0;
#elif defined(USE_X11) #elif defined(USE_X11)
Display *rDisplay = XOpenDisplay(NULL); Display *rDisplay = XOpenDisplay(NULL);
// If atoms loaded // If atoms loaded
@ -34,10 +34,10 @@ void initWindow(uintptr handle){
if (rDisplay != NULL) {LoadAtoms();} if (rDisplay != NULL) {LoadAtoms();}
} }
mData.XWin = 0; pub_mData.XWin = 0;
XCloseDisplay(rDisplay); XCloseDisplay(rDisplay);
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
mData.HWnd = 0; pub_mData.HWnd = 0;
#endif #endif
setHandle(handle); setHandle(handle);
} }
@ -67,33 +67,33 @@ MData set_handle_pid(uintptr pid, int8_t isPid){
void set_handle_pid_mData(uintptr pid, int8_t isPid){ void set_handle_pid_mData(uintptr pid, int8_t isPid){
MData win = set_handle_pid(pid, isPid); MData win = set_handle_pid(pid, isPid);
mData = win; pub_mData = win;
} }
bool is_valid() { bool is_valid() {
initWindow(initHandle); initWindow(initHandle);
if (!IsAxEnabled(true)) { if (!IsAxEnabled(true)) {
printf("%s\n", "Window: Accessibility API is disabled!\n" printf("%s\n", "Window: Accessibility API is disabled! "
"Failed to enable access for assistive devices."); "Failed to enable access for assistive devices. \n");
} }
MData actdata = get_active(); MData actdata = get_active();
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
mData.CgID = actdata.CgID; pub_mData.CgID = actdata.CgID;
mData.AxID = actdata.AxID; pub_mData.AxID = actdata.AxID;
if (mData.CgID == 0 || mData.AxID == 0) { return false; } if (pub_mData.CgID == 0 || pub_mData.AxID == 0) { return false; }
CFTypeRef r = NULL; CFTypeRef r = NULL;
// Attempt to get the window role // Attempt to get the window role
if (AXUIElementCopyAttributeValue(mData.AxID, kAXRoleAttribute, &r) == kAXErrorSuccess && r){ if (AXUIElementCopyAttributeValue(pub_mData.AxID, kAXRoleAttribute, &r) == kAXErrorSuccess && r){
CFRelease(r); CFRelease(r);
return true; return true;
} }
return false; return false;
#elif defined(USE_X11) #elif defined(USE_X11)
mData.XWin = actdata.XWin; pub_mData.XWin = actdata.XWin;
if (mData.XWin == 0) { return false; } if (pub_mData.XWin == 0) { return false; }
Display *rDisplay = XOpenDisplay(NULL); Display *rDisplay = XOpenDisplay(NULL);
// Check for a valid X-Window display // Check for a valid X-Window display
@ -103,7 +103,7 @@ bool is_valid() {
XDismissErrors(); XDismissErrors();
// Get the window PID property // Get the window PID property
void* result = GetWindowProperty(mData, WM_PID,NULL); void* result = GetWindowProperty(pub_mData, WM_PID,NULL);
if (result == NULL) { if (result == NULL) {
XCloseDisplay(rDisplay); XCloseDisplay(rDisplay);
return false; return false;
@ -115,12 +115,12 @@ bool is_valid() {
return true; return true;
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
mData.HWnd = actdata.HWnd; pub_mData.HWnd = actdata.HWnd;
if (mData.HWnd == 0) { if (pub_mData.HWnd == 0) {
return false; return false;
} }
return IsWindow(mData.HWnd) != 0; return IsWindow(pub_mData.HWnd) != 0;
#endif #endif
} }
@ -175,13 +175,13 @@ bool IsAxEnabled(bool options){
bool setHandle(uintptr handle){ bool setHandle(uintptr handle){
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
// Release the AX element // Release the AX element
if (mData.AxID != NULL) { if (pub_mData.AxID != NULL) {
CFRelease(mData.AxID); CFRelease(pub_mData.AxID);
} }
// Reset both values // Reset both values
mData.CgID = 0; pub_mData.CgID = 0;
mData.AxID = 0; pub_mData.AxID = 0;
if (handle == 0) { if (handle == 0) {
// return 0; // return 0;
@ -192,8 +192,8 @@ bool setHandle(uintptr handle){
CGWindowID cgID = (CGWindowID)handle; CGWindowID cgID = (CGWindowID)handle;
AXUIElementRef axID = GetUIElement(cgID); AXUIElementRef axID = GetUIElement(cgID);
if (axID != NULL){ if (axID != NULL){
mData.CgID = cgID; pub_mData.CgID = cgID;
mData.AxID = axID; pub_mData.AxID = axID;
// return 0; // return 0;
return true; return true;
} }
@ -201,7 +201,7 @@ bool setHandle(uintptr handle){
// return 1; // return 1;
return false; return false;
#elif defined(USE_X11) #elif defined(USE_X11)
mData.XWin = (Window)handle; pub_mData.XWin = (Window)handle;
if (handle == 0) { if (handle == 0) {
return true; return true;
} }
@ -210,10 +210,10 @@ bool setHandle(uintptr handle){
return true; return true;
} }
mData.XWin = 0; pub_mData.XWin = 0;
return false; return false;
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
mData.HWnd = (HWND)handle; pub_mData.HWnd = (HWND)handle;
if (handle == 0) { if (handle == 0) {
return true; return true;
} }
@ -222,7 +222,7 @@ bool setHandle(uintptr handle){
return true; return true;
} }
mData.HWnd = 0; pub_mData.HWnd = 0;
return false; return false;
#endif #endif
} }
@ -237,7 +237,7 @@ bool IsTopMost(void){
// XDismissErrors (); // XDismissErrors ();
// return GetState (mData.XWin, STATE_TOPMOST); // return GetState (mData.XWin, STATE_TOPMOST);
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
return (GetWindowLongPtr(mData.HWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; return (GetWindowLongPtr(pub_mData.HWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
#endif #endif
} }
@ -247,7 +247,7 @@ bool IsMinimized(void){
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
CFBooleanRef data = NULL; CFBooleanRef data = NULL;
// Determine whether the window is minimized // Determine whether the window is minimized
if (AXUIElementCopyAttributeValue(mData.AxID, kAXMinimizedAttribute, if (AXUIElementCopyAttributeValue(pub_mData.AxID, kAXMinimizedAttribute,
(CFTypeRef*) &data) == kAXErrorSuccess && data != NULL) { (CFTypeRef*) &data) == kAXErrorSuccess && data != NULL) {
// Convert resulting data into a bool // Convert resulting data into a bool
bool result = CFBooleanGetValue(data); bool result = CFBooleanGetValue(data);
@ -261,7 +261,7 @@ bool IsMinimized(void){
// XDismissErrors(); // XDismissErrors();
// return GetState(mData.XWin, STATE_MINIMIZE); // return GetState(mData.XWin, STATE_MINIMIZE);
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
return (GetWindowLongPtr(mData.HWnd, GWL_STYLE) & WS_MINIMIZE) != 0; return (GetWindowLongPtr(pub_mData.HWnd, GWL_STYLE) & WS_MINIMIZE) != 0;
#endif #endif
} }
@ -276,7 +276,7 @@ bool IsMaximized(void){
// XDismissErrors(); // XDismissErrors();
// return GetState(mData.XWin, STATE_MAXIMIZE); // return GetState(mData.XWin, STATE_MAXIMIZE);
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
return (GetWindowLongPtr(mData.HWnd, GWL_STYLE) & WS_MAXIMIZE) != 0; return (GetWindowLongPtr(pub_mData.HWnd, GWL_STYLE) & WS_MAXIMIZE) != 0;
#endif #endif
} }
@ -453,9 +453,9 @@ void SetTopMost(bool state){
#elif defined(USE_X11) #elif defined(USE_X11)
// Ignore X errors // Ignore X errors
// XDismissErrors(); // XDismissErrors();
// SetState(mData.XWin, STATE_TOPMOST, state); // SetState(pub_mData.XWin, STATE_TOPMOST, state);
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
SetWindowPos(mData.HWnd, state ? HWND_TOPMOST : HWND_NOTOPMOST, SetWindowPos(pub_mData.HWnd, state ? HWND_TOPMOST : HWND_NOTOPMOST,
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
#endif #endif
} }
@ -464,7 +464,7 @@ void close_main_window () {
// Check if the window is valid // Check if the window is valid
if (!is_valid()) { return; } if (!is_valid()) { return; }
close_window_by_Id(mData); close_window_by_Id(pub_mData);
} }
void close_window_by_PId(uintptr pid, int8_t isPid){ void close_window_by_PId(uintptr pid, int8_t isPid){
@ -502,7 +502,7 @@ char* get_main_title(){
// Check if the window is valid // Check if the window is valid
if (!is_valid()) { return "is_valid failed."; } if (!is_valid()) { return "is_valid failed."; }
return get_title_by_hand(mData); return get_title_by_hand(pub_mData);
} }
char* get_title_by_pid(uintptr pid, int8_t isPid){ char* get_title_by_pid(uintptr pid, int8_t isPid){
@ -591,7 +591,7 @@ int32_t get_PID(void) {
#if defined(IS_MACOSX) #if defined(IS_MACOSX)
pid_t pid = 0; pid_t pid = 0;
// Attempt to retrieve the window pid // Attempt to retrieve the window pid
if (AXUIElementGetPid(mData.AxID, &pid)== kAXErrorSuccess) { if (AXUIElementGetPid(pub_mData.AxID, &pid)== kAXErrorSuccess) {
return pid; return pid;
} }
return 0; return 0;
@ -600,7 +600,7 @@ int32_t get_PID(void) {
XDismissErrors(); XDismissErrors();
// Get the window PID // Get the window PID
long* result = (long*)GetWindowProperty(mData, WM_PID,NULL); long* result = (long*)GetWindowProperty(pub_mData, WM_PID,NULL);
// Check result and convert it // Check result and convert it
if (result == NULL) { return 0; } if (result == NULL) { return 0; }
@ -609,7 +609,7 @@ int32_t get_PID(void) {
return pid; return pid;
#elif defined(IS_WINDOWS) #elif defined(IS_WINDOWS)
DWORD id = 0; DWORD id = 0;
GetWindowThreadProcessId(mData.HWnd, &id); GetWindowThreadProcessId(pub_mData.HWnd, &id);
return id; return id;
#endif #endif
} }