-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (52 loc) · 1.2 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
package main
import (
"fmt"
"strconv"
"time"
"fyne.io/fyne/app"
"fyne.io/fyne/widget"
"github.com/dryaf/copytype/typer"
)
func main() {
st, err := typer.NewStringTyper(typer.KeysOSXus)
if err != nil {
panic(err)
}
app := app.New()
var waitAndTypeBtn *widget.Button
w := app.NewWindow("Copy Type")
timerLbl := widget.NewLabel("typing in # seconds")
textToType := widget.NewMultiLineEntry()
secondsTxt := widget.NewEntry()
secondsTxt.SetText("5")
waitAndTypeBtn = widget.NewButton("Wait and type", func() {
waitAndTypeBtn.Disable()
secondsTxt.SetReadOnly(true)
seconds, err := strconv.ParseInt(secondsTxt.Text, 10, 64)
if err != nil {
secondsTxt.SetText("this needs to be a number")
return
}
for ; seconds != -1; seconds-- {
time.Sleep(1 * time.Second)
secondsTxt.SetText(fmt.Sprint(seconds))
}
err = st.TypeString(textToType.Text)
waitAndTypeBtn.Enable()
secondsTxt.SetReadOnly(false)
if err != nil {
secondsTxt.SetText(err.Error())
}
})
w.SetContent(widget.NewVBox(
widget.NewLabel("Paste text you want to be typed:"),
textToType,
timerLbl,
secondsTxt,
waitAndTypeBtn,
widget.NewButton("Quit", func() {
app.Quit()
}),
))
w.ShowAndRun()
}