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