first working prototype
This commit is contained in:
22
main.go
22
main.go
@@ -13,18 +13,22 @@ func checkActive(x *int, y *int, active *bool) {
|
||||
|
||||
if cX == *x && cY == *y {
|
||||
*active = false
|
||||
fmt.Printf("Active: %v \n", *active)
|
||||
} else {
|
||||
*active = true
|
||||
fmt.Printf("Active: %v \n", *active)
|
||||
}
|
||||
|
||||
*x = cX
|
||||
*y = cY
|
||||
}
|
||||
|
||||
func moveMouse(x *int, y *int) {
|
||||
fmt.Printf("Mouse at: %v, %v \n", *x, *y)
|
||||
func moveMouse(active *bool) {
|
||||
// If inactive, move mouse to 100px right, and back
|
||||
if !*active {
|
||||
fmt.Println("Moving mouse")
|
||||
robotgo.MoveSmoothRelative(100, 0)
|
||||
time.Sleep(1 * time.Second)
|
||||
robotgo.MoveSmoothRelative(-100, 0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -33,10 +37,10 @@ func main() {
|
||||
active := true
|
||||
|
||||
// Create tickers
|
||||
// ticker1 := time.NewTicker(1 * time.Minute)
|
||||
// ticker2 := time.NewTicker(2 * time.Minute)
|
||||
ticker1 := time.NewTicker(10 * time.Second)
|
||||
ticker2 := time.NewTicker(20 * time.Second)
|
||||
ticker1 := time.NewTicker(1 * time.Minute)
|
||||
ticker2 := time.NewTicker(3 * time.Minute)
|
||||
// ticker1 := time.NewTicker(10 * time.Second)
|
||||
// ticker2 := time.NewTicker(20 * time.Second)
|
||||
|
||||
defer ticker1.Stop()
|
||||
defer ticker2.Stop()
|
||||
@@ -50,7 +54,7 @@ func main() {
|
||||
case <-ticker1.C:
|
||||
checkActive(&x, &y, &active)
|
||||
case <-ticker2.C:
|
||||
moveMouse(&x, &y)
|
||||
moveMouse(&active)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user