-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
93 lines (75 loc) · 1.55 KB
/
main.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
"github.com/go-vgo/robotgo"
"math/rand"
"time"
)
func main() {
gui()
}
func gui() {
App := app.New()
Window := App.NewWindow("AntiAFK by taillie")
sleep := 5.0
Slider := widget.NewSlider(1, 60)
Slider.Step = 1
Slider.Value = 5
Label := widget.NewLabelWithStyle("5s", fyne.TextAlignLeading, fyne.TextStyle{})
Slider.OnChanged = func(value float64) {
sleep = value
Label.SetText(fmt.Sprintf("%.0fs", value))
}
var Button *widget.Button // Объявление переменной Button внутри функции gui()
Button = widget.NewButton("Start", func() {
if Button.Text == "Start" {
Button.SetText("Stop")
go mouse(sleep)
} else {
Button.SetText("Start")
}
})
content := container.NewVBox(
container.NewGridWithColumns(2,
widget.NewLabel("Interval:"),
Label,
Slider,
),
Button,
)
Window.SetContent(content)
Window.ShowAndRun()
}
func mouse(sleep float64) {
rand.Seed(time.Now().UnixNano())
scrW, scrH := robotgo.GetScreenSize()
for {
x := rand.Intn(scrW)
y := rand.Intn(scrH)
robotgo.MoveMouseSmooth(x, y)
time.Sleep(time.Duration(sleep) * time.Second)
}
}
/** func keyboard(sleep float64) {
rand.Seed(time.Now().UnixNano())
for {
keyIndex := rand.Intn(4)
var key string
switch keyIndex {
case 0:
key = "w"
case 1:
key = "a"
case 2:
key = "s"
case 3:
key = "d"
}
robotgo.KeyTap(key)
time.Sleep(time.Duration(sleep) * time.Second)
}
} **/