robotgo
robotgo copied to clipboard
GetBounds returns wrong values
- Robotgo version (or commit ref): v0.80.0.845, Sierra Nevada!
- Go version:
$go version
go version go1.12 darwin/amd64
- Gcc version:
$gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Thread model: posix
- Operating system and bit: macOS Mojave x64
- Resolution: 2880 x 1800
- Can you reproduce the bug at Examples:
- [x] Yes (provide example code)
- [ ] No
- [ ] Not relevant
- Provide example code:
package main
import (
"fmt"
"strings"
"github.com/go-vgo/robotgo"
)
func main() {
fmt.Println("Version:", robotgo.Version)
process, _ := robotgo.Process()
for _, p := range process {
if strings.Contains(strings.ToLower(p.Name), "macpass") {
mx, my := robotgo.GetMousePos()
x, y, w, h := robotgo.GetBounds(p.Pid)
robotgo.SetActive(robotgo.GetHandPid(p.Pid))
fmt.Println("Bounds:", robotgo.IsValid(), x, y, w, h)
fmt.Println("MousePos:", mx, my)
bitmap := robotgo.CaptureScreen()
defer robotgo.FreeBitmap(bitmap)
robotgo.SaveBitmap(bitmap, "test.png")
}
}
}
- Log gist:
$go run main.go
Version: v0.80.0.845, Sierra Nevada!
Bounds: true 974848 512 -1 197
MousePos: 509 650
Description

Also having the same issue, any investigation done?
Has this progressed?
I researched this further as was getting no response here. Turns out osx will return nil when you ask for the bounds of another application and therefore this is not possible.
OS: Ubuntu 16.04
Description: the value of X variable is obviously greater than screen size
Code
fpid, err := robotgo.FindIds("Game")
if err != nil {
log.Fatal(err)
}
pid := fpid[0]
fmt.Println("pid: ", pid)
x, y, w, h := robotgo.GetBounds(pid)
fmt.Printf("x: %d, y: %d, w: %d, h: %d \n", x, y, w, h)
sW, sH := robotgo.GetScreenSize()
fmt.Printf("screen size: %d, %d", sW, sH)
Output
pid: 11806
x: 2555, y: 150, w: 1024, h: 796
screen size: 1920, 1080
have the same problem. how to test/debug where goes wrong in win_sys.h
Bounds get_bounds(uintptr pid, uintptr isHwnd){