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 {
|
if cX == *x && cY == *y {
|
||||||
*active = false
|
*active = false
|
||||||
fmt.Printf("Active: %v \n", *active)
|
|
||||||
} else {
|
} else {
|
||||||
*active = true
|
*active = true
|
||||||
fmt.Printf("Active: %v \n", *active)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*x = cX
|
*x = cX
|
||||||
*y = cY
|
*y = cY
|
||||||
}
|
}
|
||||||
|
|
||||||
func moveMouse(x *int, y *int) {
|
func moveMouse(active *bool) {
|
||||||
fmt.Printf("Mouse at: %v, %v \n", *x, *y)
|
// 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() {
|
func main() {
|
||||||
@@ -33,10 +37,10 @@ func main() {
|
|||||||
active := true
|
active := true
|
||||||
|
|
||||||
// Create tickers
|
// Create tickers
|
||||||
// ticker1 := time.NewTicker(1 * time.Minute)
|
ticker1 := time.NewTicker(1 * time.Minute)
|
||||||
// ticker2 := time.NewTicker(2 * time.Minute)
|
ticker2 := time.NewTicker(3 * time.Minute)
|
||||||
ticker1 := time.NewTicker(10 * time.Second)
|
// ticker1 := time.NewTicker(10 * time.Second)
|
||||||
ticker2 := time.NewTicker(20 * time.Second)
|
// ticker2 := time.NewTicker(20 * time.Second)
|
||||||
|
|
||||||
defer ticker1.Stop()
|
defer ticker1.Stop()
|
||||||
defer ticker2.Stop()
|
defer ticker2.Stop()
|
||||||
@@ -50,7 +54,7 @@ func main() {
|
|||||||
case <-ticker1.C:
|
case <-ticker1.C:
|
||||||
checkActive(&x, &y, &active)
|
checkActive(&x, &y, &active)
|
||||||
case <-ticker2.C:
|
case <-ticker2.C:
|
||||||
moveMouse(&x, &y)
|
moveMouse(&active)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user