-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrogo.go
65 lines (61 loc) · 1.41 KB
/
frogo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
"github.com/go-vgo/robotgo"
"golang.design/x/hotkey"
"math/rand"
"os"
"strconv"
"time"
)
func gui() {
app := app.New()
window := app.NewWindow("FRoGo (Zum Beenden: Strg + Shift + q)")
label := widget.NewLabel("Minuten:")
entry := widget.NewEntry()
button := widget.NewButton("Start", func() {
cli(strconv.Atoi(entry.Text))
})
grid := container.New(layout.NewGridLayout(3), label, entry, button)
window.SetIcon(theme.FyneLogo())
window.SetContent(grid)
window.Resize(fyne.NewSize(500, 0))
window.SetFixedSize(true)
window.CenterOnScreen()
go func() {
hotkey := hotkey.New([]hotkey.Modifier{hotkey.ModCtrl, hotkey.ModShift}, hotkey.KeyQ)
hotkey.Register()
for range hotkey.Keydown() {
os.Exit(0)
}
}()
window.ShowAndRun()
}
func cli(in int, er error) {
timeout := time.After(time.Duration(in) * time.Minute)
if in <= 0 || er != nil {
timeout = time.After(24 * time.Hour)
}
for {
select {
case <-timeout:
os.Exit(0)
default:
robotgo.MouseSleep = 100
width, height := robotgo.GetScreenSize()
rand.Seed(time.Now().UnixNano())
robotgo.MoveSmooth(rand.Intn(width), rand.Intn(height), 1.1/3, 1.1)
robotgo.Click("right")
time.Sleep(2 * time.Second)
robotgo.KeyTap("esc")
}
}
}
func main() {
gui()
}