I ran into some strange behavior when testing mouse clicks and mouse positions. When I click the left mouse button and hold it down it registers a click. When I release the button it registers a click. There seems to be a difference between "mouse click down" and "mouse click up".
The behavior is different when I move the mouse. When I click the left mouse button and hold it down it registers a click. When I move the mouse while holding the left mouse button and release on another position there is no click registered.
- Robotgo version (or commit ref): fe836c3
- Go version: go1.10.1 darwin/amd64
- Gcc version: Apple LLVM version 9.1.0 (clang-902.0.39.2)
- Operating system and bit: macOS 10.13.5 (17F77)
package main
import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
"github.com/go-vgo/robotgo"
)
func main() {
sigs := make(chan os.Signal, 1)
done := make(chan bool, 1)
quit := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGINFO)
// Wait for signal
go func() {
for {
select {
case sig := <-sigs:
if sig.String() == "information request" {
log.Printf(" <- Got information request %v\n", sig)
} else {
log.Printf(" <- Got signal: %v\n", sig) // information request
done <- true
}
}
}
}()
// Print mouseposition
go func() {
var x, y int
for {
select {
case <-done:
log.Println("Exiting...")
quit <- true
default:
cx, cy := robotgo.GetMousePos()
if cx != x && cy != y {
x = cx
y = cy
log.Printf("(x pos): %v (y pos): %v \n", cx, cy)
}
}
}
}()
// Print mouse click and position
go func() {
for {
cx, cy := robotgo.GetMousePos()
if robotgo.AddEvent("mleft") == 0 {
fmt.Printf("mouse left button pressed on (x pos): %v (y pos): %v\n", cx, cy)
}
}
}()
<-quit
}
I ran into some strange behavior when testing mouse clicks and mouse positions. When I click the left mouse button and hold it down it registers a click. When I release the button it registers a click. There seems to be a difference between "mouse click down" and "mouse click up".
The behavior is different when I move the mouse. When I click the left mouse button and hold it down it registers a click. When I move the mouse while holding the left mouse button and release on another position there is no click registered.