Open elonzh opened 5 years ago
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
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)
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){
Running the exact code from @caryyu on MacOS (M3) gives:
x: 3629056, y: 3627784, w: 1668311156, h: -1177118969
That seems just a little bit off to me.
As this will likely never be fixed, I cheated and called out to AppleScript to get the x, y, w, h. Using Mack:
str, err := mack.Tell("System Events", `
tell application process "<<window_name_goes_here>>"
get { position, size } of window 1
end tell
`)
fmt.Println(str) // 0, 38, 1514, 884
Same problem, as well as on macos an application may have multiple window appears on multiple desktop. I think the API should also fit that.
Description