-
Notifications
You must be signed in to change notification settings - Fork 4
/
input.clj
37 lines (32 loc) · 894 Bytes
/
input.clj
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
(ns cuic.input
(:require [cuic.core :refer [-run-mutation -browser *config*]]
[cuic.impl.input :as input]))
(defn type!
"Types the given keys and text with the keyboard"
[& keys]
(-run-mutation
(input/type! (-browser) keys (:typing-speed *config*))))
(defn keyup!
"Triggers key-up keyboard event"
[key]
(-run-mutation
(input/keyup! (-browser) key)))
(defn keydown!
"Triggers key-down keyboard event"
[key]
(-run-mutation
(input/keydown! (-browser) key)))
(defn move-mouse!
"Moves mouse to the given (x,y) coordinate"
[x y]
{:pre [(number? x)
(number? y)]}
(-run-mutation
(input/mouse-move! (-browser) {:x x :y y})))
(defn click!
"Moves mouse to the given (x,y) coordinate and then clicks that position"
[x y]
{:pre [(number? x)
(number? y)]}
(-run-mutation
(input/mouse-click! (-browser) {:x x :y y})))