|
@@ -22,9 +22,17 @@ func (p Point) String() string {
|
|
|
return fmt.Sprintf("(%v, %v)", p.X, p.Y)
|
|
|
}
|
|
|
|
|
|
-func (p Point) Click() {
|
|
|
+func (p Point) Click(button ...string) {
|
|
|
+ buttonToClick := "left"
|
|
|
+ if len(button) > 0 && (button[0] == "left" || button[0] == "right") {
|
|
|
+ buttonToClick = button[0]
|
|
|
+ }
|
|
|
robotgo.Move(p.X, p.Y)
|
|
|
- robotgo.Click("left", false)
|
|
|
+ robotgo.Click(buttonToClick, false)
|
|
|
+}
|
|
|
+
|
|
|
+func (p Point) RightClick() {
|
|
|
+ p.Click("right")
|
|
|
}
|
|
|
|
|
|
func (p1 *Point) GetDistance(p2 *Point) float64 {
|
|
@@ -145,7 +153,16 @@ func StringOscillator(s string, amplitude int) chan string {
|
|
|
return c
|
|
|
}
|
|
|
|
|
|
-func ClickRepeteadly(s *SavedGroups, c chan os.Signal) {
|
|
|
+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) {
|
|
|
for index, g := range s.Groups {
|
|
|
fmt.Printf("- Press %v to select %v\n", index+1, g.Name)
|
|
|
}
|
|
@@ -159,6 +176,9 @@ func ClickRepeteadly(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)
|
|
@@ -207,7 +227,7 @@ func cleanUp(c chan os.Signal) chan int {
|
|
|
func interactWithUser(s *SavedGroups, yamlFile string, c chan os.Signal) {
|
|
|
addSavedGroup(s)
|
|
|
storeSavedGroups(s, yamlFile)
|
|
|
- ClickRepeteadly(s, c)
|
|
|
+ ClickRepeatedly(s, c)
|
|
|
}
|
|
|
|
|
|
func RunAutoClicker() {
|