-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
49 lines (39 loc) · 1.01 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
package main
import (
"flag"
"log"
"time"
"github.com/stephen-fox/user32util"
)
func main() {
sendAfter := flag.Duration("s", 1*time.Second, "The amount of time in seconds to wait before sending value")
mouse := flag.Bool("mouse", false, "Send mouse input instead of keyboard input")
flag.Parse()
user32, err := user32util.LoadUser32DLL()
if err != nil {
log.Fatalf("failed to load user32.dll - %s", err.Error())
}
if *mouse {
for {
log.Printf("will send 0x%X in %s", 0x41, sendAfter.String())
time.Sleep(*sendAfter)
err := user32util.SendMouseInput(user32util.MouseInput{
DwFlags: user32util.MouseEventFRightDown,
}, user32)
if err != nil {
log.Fatalf("failed to send input - %s", err.Error())
}
}
} else {
for {
log.Printf("will send 0x%X in %s", 0x41, sendAfter.String())
time.Sleep(*sendAfter)
err := user32util.SendKeydbInput(user32util.KeybdInput{
WVK: 0x41,
}, user32)
if err != nil {
log.Fatalf("failed to send input - %s", err.Error())
}
}
}
}