Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
603b4e87ef | |||
91825584cd |
@ -6,6 +6,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -22,9 +23,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,6 +154,15 @@ 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) {
|
||||
for index, g := range s.Groups {
|
||||
fmt.Printf("- Press %v to select %v\n", index+1, g.Name)
|
||||
@ -159,6 +177,9 @@ 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)
|
||||
@ -167,10 +188,32 @@ func ClickRepeatedly(s *SavedGroups, c chan os.Signal) {
|
||||
}
|
||||
o := StringOscillator(".", 15)
|
||||
var t int
|
||||
n := 1
|
||||
var minDistance float64
|
||||
for {
|
||||
for _, p := range selection.Points {
|
||||
p.Click()
|
||||
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()
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
fmt.Println(<-o)
|
||||
|
Loading…
x
Reference in New Issue
Block a user