Compare commits
No commits in common. "603b4e87efff50b7c266d52c29c6f8115b1b8fc3" and "026f522a8982c2979240abcc429f786928d321b8" have entirely different histories.
603b4e87ef
...
026f522a89
@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gogs.davte.it/Davte/autoclick/helper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
helper.RunAutoClicker()
|
||||
}
|
9
cmd/main/main.go
Normal file
9
cmd/main/main.go
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gogs.davte.it/davte/autoclick"
|
||||
)
|
||||
|
||||
func main() {
|
||||
autoclick.RunAutoClicker()
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package helper
|
||||
package autoclick
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -23,17 +22,9 @@ func (p Point) String() string {
|
||||
return fmt.Sprintf("(%v, %v)", p.X, p.Y)
|
||||
}
|
||||
|
||||
func (p Point) Click(button ...string) {
|
||||
buttonToClick := "left"
|
||||
if len(button) > 0 && (button[0] == "left" || button[0] == "right") {
|
||||
buttonToClick = button[0]
|
||||
}
|
||||
func (p Point) Click() {
|
||||
robotgo.Move(p.X, p.Y)
|
||||
robotgo.Click(buttonToClick, false)
|
||||
}
|
||||
|
||||
func (p Point) RightClick() {
|
||||
p.Click("right")
|
||||
robotgo.Click("left", false)
|
||||
}
|
||||
|
||||
func (p1 *Point) GetDistance(p2 *Point) float64 {
|
||||
@ -154,16 +145,7 @@ func StringOscillator(s string, amplitude int) chan string {
|
||||
return c
|
||||
}
|
||||
|
||||
func press(key string) {
|
||||
robotgo.KeyTap(key)
|
||||
}
|
||||
|
||||
func keyboardWrite(s string) {
|
||||
robotgo.TypeStr(s)
|
||||
robotgo.MilliSleep(100)
|
||||
}
|
||||
|
||||
func ClickRepeatedly(s *SavedGroups, c chan os.Signal) {
|
||||
func ClickRepeteadly(s *SavedGroups) {
|
||||
for index, g := range s.Groups {
|
||||
fmt.Printf("- Press %v to select %v\n", index+1, g.Name)
|
||||
}
|
||||
@ -177,9 +159,6 @@ func ClickRepeatedly(s *SavedGroups, c chan os.Signal) {
|
||||
fmt.Scanln(&discard)
|
||||
continue
|
||||
}
|
||||
if choice > len(s.Groups) {
|
||||
choice = 0
|
||||
}
|
||||
}
|
||||
selection := s.Groups[choice-1]
|
||||
fmt.Printf("You selected %v. I'll be clicking in the following positions:\n", selection.Name)
|
||||
@ -188,32 +167,10 @@ func ClickRepeatedly(s *SavedGroups, c chan os.Signal) {
|
||||
}
|
||||
o := StringOscillator(".", 15)
|
||||
var t int
|
||||
n := 1
|
||||
var minDistance float64
|
||||
for {
|
||||
for i, p := range selection.Points {
|
||||
if selection.Name == "akoya" { // hardcoded for Akoya presentation. #TODO: better handling (selection action list)
|
||||
if i == 0 {
|
||||
p.RightClick()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
press("v")
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
} else if i == 1 {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
p.Click()
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
keyboardWrite(strconv.Itoa(n))
|
||||
n++
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
press("enter")
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
} else {
|
||||
p.Click()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
} else {
|
||||
p.Click()
|
||||
}
|
||||
for _, p := range selection.Points {
|
||||
p.Click()
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
fmt.Println(<-o)
|
||||
@ -231,7 +188,6 @@ func ClickRepeatedly(s *SavedGroups, c chan os.Signal) {
|
||||
}
|
||||
if t >= 10 {
|
||||
fmt.Println("You stayed away too long, exiting...")
|
||||
c <- os.Interrupt
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -247,19 +203,15 @@ func cleanUp(c chan os.Signal) chan int {
|
||||
return r
|
||||
}
|
||||
|
||||
func interactWithUser(s *SavedGroups, yamlFile string, c chan os.Signal) {
|
||||
addSavedGroup(s)
|
||||
storeSavedGroups(s, yamlFile)
|
||||
ClickRepeatedly(s, c)
|
||||
}
|
||||
|
||||
func RunAutoClicker() {
|
||||
c := make(chan os.Signal, 1)
|
||||
quit := cleanUp(c)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
yamlFile := "SavedGroups.yaml"
|
||||
s := getSavedGroups(yamlFile)
|
||||
go interactWithUser(s, yamlFile, c)
|
||||
addSavedGroup(s)
|
||||
storeSavedGroups(s, yamlFile)
|
||||
go ClickRepeteadly(s)
|
||||
if <-quit == 1 {
|
||||
fmt.Println("Exiting...")
|
||||
} else {
|
Loading…
x
Reference in New Issue
Block a user