Compare commits
10 Commits
026f522a89
...
main
Author | SHA1 | Date | |
---|---|---|---|
b20a46cd37 | |||
0984a36f59
|
|||
b21e09cbb7
|
|||
340e193ab6
|
|||
4d2dbe71e9
|
|||
0e7d512413
|
|||
916edd704b
|
|||
30f017af72
|
|||
2c12ef6df8
|
|||
1b9d849472
|
28
README.md
28
README.md
@@ -1,3 +1,29 @@
|
||||
# autoclick
|
||||
|
||||
Go auto-clicker
|
||||
Go auto-clicker that stores groups of locations.
|
||||
Based on [Robotgo](https://github.com/go-vgo/robotgo).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Depending on your OS, you may require
|
||||
[different dependencies](https://github.com/go-vgo/robotgo?tab=readme-ov-file#requirements).
|
||||
|
||||
If you are running MacOS, you just need to install Xcode Command Line Tools
|
||||
and grant Go the accessibility permissions when prompted from the system.
|
||||
|
||||
```sh
|
||||
xcode-select --install
|
||||
```
|
||||
|
||||
Finally, once dependencies are met, to install autoclick run:
|
||||
|
||||
```bash
|
||||
go install gogs.davte.it/Davte/autoclick@latest
|
||||
```
|
||||
|
||||
To launch autoclick from any path, add this to your bash profile or bashrc:
|
||||
|
||||
```bash
|
||||
export PATH="$PATH:/$HOME/go/bin"
|
||||
```
|
9
autoclick.go
Normal file
9
autoclick.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gogs.davte.it/Davte/autoclick/helper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
helper.RunAutoClicker()
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gogs.davte.it/davte/autoclick"
|
||||
)
|
||||
|
||||
func main() {
|
||||
autoclick.RunAutoClicker()
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package autoclick
|
||||
package helper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -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) {
|
||||
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) {
|
||||
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,6 +208,7 @@ func ClickRepeteadly(s *SavedGroups) {
|
||||
}
|
||||
if t >= 10 {
|
||||
fmt.Println("You stayed away too long, exiting...")
|
||||
c <- os.Interrupt
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -203,15 +224,19 @@ 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)
|
||||
addSavedGroup(s)
|
||||
storeSavedGroups(s, yamlFile)
|
||||
go ClickRepeteadly(s)
|
||||
go interactWithUser(s, yamlFile, c)
|
||||
if <-quit == 1 {
|
||||
fmt.Println("Exiting...")
|
||||
} else {
|
Reference in New Issue
Block a user