Skip to content

Commit

Permalink
Merge pull request #549 from go-vgo/test-pr
Browse files Browse the repository at this point in the history
Update & Add: unified use the int to replace int32...
  • Loading branch information
vcaesar authored Nov 28, 2022
2 parents fc5dac6 + 2f2ed59 commit be6984f
Show file tree
Hide file tree
Showing 16 changed files with 170 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
docker:
# using custom image, see .circleci/images/primary/Dockerfile
# - image: govgo/robotgoci:1.10.3
- image: golang:1.19.1
- image: golang:1.19.3
working_directory: /gopath/src/github.com/go-vgo/robotgo
steps:
- checkout
Expand Down
2 changes: 1 addition & 1 deletion .circleci/images/primary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FROM golang:1.10.1
FROM golang:1.19.1-stretch AS build
FROM golang:1.19.3-stretch AS build
# FROM govgo/go:1.11.1

RUN apt update && apt install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ environment:
PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
# - COMPILER: MINGW_W64
# ARCHITECTURE: x64
GOVERSION: 1.19.1
GOVERSION: 1.19.3
# GOPATH: c:\gopath

# scripts that run after cloning repository
Expand Down
2 changes: 1 addition & 1 deletion examples/window/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func findIds() {

if len(fpid) > 0 {
robotgo.KeyTap("a", fpid[0])
robotgo.TypeStr("Hi galaxy!", int(fpid[0]))
robotgo.TypeStr("Hi galaxy!", fpid[0])

robotgo.KeyToggle("a", fpid[0], "cmd")
robotgo.KeyToggle("a", fpid[0], "cmd", "up")
Expand Down
18 changes: 8 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,23 @@ require (
// github.com/robotn/gohook v0.31.3
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770
github.com/vcaesar/gops v0.23.0
github.com/vcaesar/gops v0.30.0
github.com/vcaesar/imgo v0.30.1
github.com/vcaesar/keycode v0.10.0
github.com/vcaesar/tt v0.20.0
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 // indirect
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
golang.org/x/image v0.1.0 // indirect
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
github.com/otiai10/mint v1.3.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.22.4 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/shirou/gopsutil/v3 v3.22.10 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
golang.org/x/sys v0.2.0 // indirect
)

// replace golang.org/x/sys => github.com/golang/sys v0.0.0-20190109145017-48ac38b7c8cb
Expand Down
63 changes: 43 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c h1:VtwQ41oftZwlMnOEbMWQtSEUgU64U4s+GHk7hZK+jtY=
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c/go.mod h1:JKx41uQRwqlTZabZc+kILPrO/3jlKnQ2Z8b7YiVw5cE=
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/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
Expand All @@ -19,51 +20,73 @@ github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c h1:NRoLoZvkBTKvR5gQLgA3e0hqjkY9u1wm+iOL45VN/qI=
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934 h1:2lhSR8N3T6I30q096DT7/5AKEIcf1vvnnWAmS0wfnNY=
github.com/robotn/xgb v0.0.0-20190912153532-2cb92d044934/go.mod h1:SxQhJskUJ4rleVU44YvnrdvxQr0tKy5SRSigBrCgyyQ=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770 h1:2uX8QRLkkxn2EpAQ6I3KhA79BkdRZfvugJUzJadiJwk=
github.com/robotn/xgbutil v0.0.0-20190912154524-c861d6f87770/go.mod h1:svkDXUDQjUiWzLrA0OZgHc4lbOts3C+uRfP6/yjwYnU=
github.com/shirou/gopsutil/v3 v3.22.4 h1:srAQaiX6jX/cYL6q29aE0m8lOskT9CurZ9N61YR3yoI=
github.com/shirou/gopsutil/v3 v3.22.4/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM=
github.com/shirou/gopsutil/v3 v3.22.10 h1:4KMHdfBRYXGF9skjDWiL4RA2N+E8dRdodU/bOZpPoVg=
github.com/shirou/gopsutil/v3 v3.22.10/go.mod h1:QNza6r4YQoydyCfo6rH0blGfKahgibh4dQmV5xdFkQk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+KdJV0CM=
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/vcaesar/gops v0.23.0 h1:gY/E5UJfLpImJjE7tiTJIVRcKOWxi7YX1J/CUHK8gXk=
github.com/vcaesar/gops v0.23.0/go.mod h1:3IepRPE6qK9Wy8MGLJx2N3o77fuO1Ec7FvPHyEuou8I=
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
github.com/vcaesar/gops v0.30.0 h1:970FznFxZP8ku0zckJRO+pI2fFhg3uJ0z+sQS0NHP4o=
github.com/vcaesar/gops v0.30.0/go.mod h1:xV1wieUA4D9RaNQ8lf8AwPZ8bl+x/MM5w3SsMCr5KVs=
github.com/vcaesar/imgo v0.30.1 h1:B7QMm2mZY+SGoEvvJwNi+eAv21ptvk2YT1IbP2OzyLE=
github.com/vcaesar/imgo v0.30.1/go.mod h1:n4EluJIN/0UYYGPHBCY/BWlIjdRUdY5U6obtP2lrgdM=
github.com/vcaesar/keycode v0.10.0 h1:Qx5QE8ZXHyRyjoA2QOxBp25OKMKB+zxMVqm0FWGV0d4=
github.com/vcaesar/keycode v0.10.0/go.mod h1:JNlY7xbKsh+LAGfY2j4M3znVrGEm5W1R8s/Uv6BJcfQ=
github.com/vcaesar/tt v0.20.0 h1:9t2Ycb9RNHcP0WgQgIaRKJBB+FrRdejuaL6uWIHuoBA=
github.com/vcaesar/tt v0.20.0/go.mod h1:GHPxQYhn+7OgKakRusH7KJ0M5MhywoeLb8Fcffs/Gtg=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410 h1:hTftEOvwiOq2+O8k2D5/Q7COC7k5Qcrgc2TFURJYnvQ=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/image v0.1.0 h1:r8Oj8ZA2Xy12/b5KZYj3tuv7NG/fBz3TwQVvpJ9l8Rk=
golang.org/x/image v0.1.0/go.mod h1:iyPr49SD/G/TBxYVB/9RRtGUT5eNbo2u4NamWeQcD5c=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201018230417-eeed37f84f13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
14 changes: 7 additions & 7 deletions ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import ps "github.com/vcaesar/gops"

// Nps process struct
type Nps struct {
Pid int32
Pid int
Name string
}

// Pids get the all process id
func Pids() ([]int32, error) {
func Pids() ([]int, error) {
return ps.Pids()
}

// PidExists determine whether the process exists
func PidExists(pid int32) (bool, error) {
func PidExists(pid int) (bool, error) {
return ps.PidExists(pid)
}

Expand All @@ -45,7 +45,7 @@ func Process() ([]Nps, error) {
}

// FindName find the process name by the process id
func FindName(pid int32) (string, error) {
func FindName(pid int) (string, error) {
return ps.FindName(pid)
}

Expand All @@ -57,12 +57,12 @@ func FindNames() ([]string, error) {
// FindIds finds the all processes named with a subset
// of "name" (case insensitive),
// return matched IDs.
func FindIds(name string) ([]int32, error) {
func FindIds(name string) ([]int, error) {
return ps.FindIds(name)
}

// FindPath find the process path by the process pid
func FindPath(pid int32) (string, error) {
func FindPath(pid int) (string, error) {
return ps.FindPath(pid)
}

Expand All @@ -72,6 +72,6 @@ func Run(path string) ([]byte, error) {
}

// Kill kill the process by PID
func Kill(pid int32) error {
func Kill(pid int) error {
return ps.Kill(pid)
}
70 changes: 35 additions & 35 deletions robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,55 +920,55 @@ func GetActive() C.MData {
}

// MinWindow set the window min
func MinWindow(pid int32, args ...interface{}) {
func MinWindow(pid int, args ...interface{}) {
var (
state = true
hwnd int
isPid int
)

if len(args) > 0 {
state = args[0].(bool)
}
if len(args) > 1 {
hwnd = args[1].(int)
isPid = args[1].(int)
}

C.min_window(C.uintptr(pid), C.bool(state), C.uintptr(hwnd))
C.min_window(C.uintptr(pid), C.bool(state), C.int8_t(isPid))
}

// MaxWindow set the window max
func MaxWindow(pid int32, args ...interface{}) {
func MaxWindow(pid int, args ...interface{}) {
var (
state = true
hwnd int
isPid int
)

if len(args) > 0 {
state = args[0].(bool)
}
if len(args) > 1 {
hwnd = args[1].(int)
isPid = args[1].(int)
}

C.max_window(C.uintptr(pid), C.bool(state), C.uintptr(hwnd))
C.max_window(C.uintptr(pid), C.bool(state), C.int8_t(isPid))
}

// CloseWindow close the window
func CloseWindow(args ...int32) {
func CloseWindow(args ...int) {
if len(args) <= 0 {
C.close_main_window()
return
}

var hwnd, isHwnd int32
var pid, isPid int
if len(args) > 0 {
hwnd = args[0]
pid = args[0]
}
if len(args) > 1 {
isHwnd = args[1]
isPid = args[1]
}

C.close_window_by_PId(C.uintptr(hwnd), C.uintptr(isHwnd))
C.close_window_by_PId(C.uintptr(pid), C.int8_t(isPid))
}

// SetHandle set the window handle
Expand All @@ -978,23 +978,23 @@ func SetHandle(hwnd int) {
}

// SetHandlePid set the window handle by pid
func SetHandlePid(pid int32, args ...int32) {
var isHwnd int32
func SetHandlePid(pid int, args ...int) {
var isPid int
if len(args) > 0 {
isHwnd = args[0]
isPid = args[0]
}

C.set_handle_pid_mData(C.uintptr(pid), C.uintptr(isHwnd))
C.set_handle_pid_mData(C.uintptr(pid), C.int8_t(isPid))
}

// GetHandPid get handle mdata by pid
func GetHandPid(pid int32, args ...int32) C.MData {
var isHwnd int32
func GetHandPid(pid int, args ...int) C.MData {
var isPid int
if len(args) > 0 {
isHwnd = args[0]
isPid = args[0]
}

return C.set_handle_pid(C.uintptr(pid), C.uintptr(isHwnd))
return C.set_handle_pid(C.uintptr(pid), C.int8_t(isPid))
}

// GetHandle get the window handle
Expand All @@ -1018,8 +1018,8 @@ func GetBHandle() int {
return ghwnd
}

func cgetTitle(hwnd, isHwnd int32) string {
title := C.get_title_by_pid(C.uintptr(hwnd), C.uintptr(isHwnd))
func cgetTitle(pid, isPid int) string {
title := C.get_title_by_pid(C.uintptr(pid), C.int8_t(isPid))
gtitle := C.GoString(title)

return gtitle
Expand All @@ -1033,7 +1033,7 @@ func cgetTitle(hwnd, isHwnd int32) string {
//
// ids, _ := robotgo.FindIds()
// robotgo.GetTitle(ids[0])
func GetTitle(args ...int32) string {
func GetTitle(args ...int) string {
if len(args) <= 0 {
title := C.get_main_title()
gtitle := C.GoString(title)
Expand All @@ -1048,20 +1048,20 @@ func GetTitle(args ...int32) string {
}

// GetPid get the process id return int32
func GetPid() int32 {
func GetPid() int {
pid := C.get_PID()
return int32(pid)
return int(pid)
}

// internalGetBounds get the window bounds
func internalGetBounds(pid int32, hwnd int) (int, int, int, int) {
bounds := C.get_bounds(C.uintptr(pid), C.uintptr(hwnd))
func internalGetBounds(pid, isPid int) (int, int, int, int) {
bounds := C.get_bounds(C.uintptr(pid), C.int8_t(isPid))
return int(bounds.X), int(bounds.Y), int(bounds.W), int(bounds.H)
}

// internalGetClient get the window client bounds
func internalGetClient(pid int32, hwnd int) (int, int, int, int) {
bounds := C.get_client(C.uintptr(pid), C.uintptr(hwnd))
func internalGetClient(pid, isPid int) (int, int, int, int) {
bounds := C.get_client(C.uintptr(pid), C.int8_t(isPid))
return int(bounds.X), int(bounds.Y), int(bounds.W), int(bounds.H)
}

Expand All @@ -1071,19 +1071,19 @@ func Is64Bit() bool {
return bool(b)
}

func internalActive(pid int32, hwnd int) {
C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
func internalActive(pid, isPid int) {
C.active_PID(C.uintptr(pid), C.int8_t(isPid))
}

// ActivePid active the window by Pid,
// If args[0] > 0 on the Windows platform via a window handle to active
// func ActivePid(pid int32, args ...int) {
// var hwnd int
// var isPid int
// if len(args) > 0 {
// hwnd = args[0]
// isPid = args[0]
// }

// C.active_PID(C.uintptr(pid), C.uintptr(hwnd))
// C.active_PID(C.uintptr(pid), C.uintptr(isPid))
// }

// ActiveName active the window by name
Expand Down
Loading

0 comments on commit be6984f

Please sign in to comment.