This module implements keyboard and mouse binds and input emulation.
input.send(...)
(+)
or (-)
to specify key press or release. If neither is used, the key is both pressed and released;!
for ALT, ^
for CTRL, +
for SHIFT, #
for WIN key;key
table below).input.sendtext(text)
text
.
input.bind(key, func[, limit])
key
, which can be a numeric code or a string with modifiers and key name as specified in input.send
.
The original key press will be consumed. Each key press runs func
in a new thread.
limit
specifies simultaneous execution limit for the hotkey.
input.hook(func)
func
every time any key is pressed or released. func
can take one argument, which is the key that was pressed or released
(negative value indicates released key).
input.ontext(text, func)
func
will be called when a specific text sequence is entered.
input.onsequence(sequence, func)
func
will be called when a specific key sequence is entered (sequence format as in input.send
).
input.newlist()
input.list
, which supports the following methods:
input.list:addkeys(keys)
input.send
.
input.list:addtext(text)
text
to the list.
input.list:addmove(x, y[, rel])
(x,y)
(absolute or relative) to the list.
input.list:delay(t)
t
seconds.
input.list:randomize(x[, rel])
rel
is false
, set the delay before every key to a random duration between (1-x, 1+x)
seconds.
Otherwise, multiply all delays by a random number in range (1-x, 1+x)
.
input.list:length()
input.list:duration()
input.list:send([t])
t
seconds.
input.list:recordstart() input.list:recordstop()
input.list:dump()
input.list:undump(str)
str
to the list.
key.pressed(key)
key
is key name or numeric value).
key.name(id)
id
.
key.waitup(key) key.waitdown(key)
key.BACKSPACE = 8 key.TAB = 9 key.ENTER = 13 key.SHIFT = 16 key.CONTROL = 17 key.ALT = 18 key.PAUSE = 19 key.CAPSLOCK = 20 key.ESCAPE = 27 key.SPACE = 32 key.PAGEUP = 33 key.PAGEDOWN = 34 key.END = 35 key.HOME = 36 key.LEFT = 37 key.UP = 38 key.RIGHT = 39 key.DOWN = 40 key.PRINTSCREEN = 44 key.INSERT = 45 key.DELETE = 46 key["0"] = 48 key["1"] = 49 key["2"] = 50 key["3"] = 51 key["4"] = 52 key["5"] = 53 key["6"] = 54 key["7"] = 55 key["8"] = 56 key["9"] = 57 key.A = 65 key.B = 66 key.C = 67 key.D = 68 key.E = 69 key.F = 70 key.G = 71 key.H = 72 key.I = 73 key.J = 74 key.K = 75 key.L = 76 key.M = 77 key.N = 78 key.O = 79 key.P = 80 key.Q = 81 key.R = 82 key.S = 83 key.T = 84 key.U = 85 key.V = 86 key.W = 87 key.X = 88 key.Y = 89 key.Z = 90 key.LWIN = 91 key.RWIN = 92 key.APPS = 93 key.NUM0 = 96 key.NUM1 = 97 key.NUM2 = 98 key.NUM3 = 99 key.NUM4 = 100 key.NUM5 = 101 key.NUM6 = 102 key.NUM7 = 103 key.NUM8 = 104 key.NUM9 = 105 key.MULTIPLY = 106 key.ADD = 107 key.SUBTRACT = 109 key.DECIMAL = 110 key.DIVIDE = 111 key.F1 = 112 key.F2 = 113 key.F3 = 114 key.F4 = 115 key.F5 = 116 key.F6 = 117 key.F7 = 118 key.F8 = 119 key.F9 = 120 key.F10 = 121 key.F11 = 122 key.F12 = 123 key.F13 = 124 key.F14 = 125 key.F15 = 126 key.F16 = 127 key.F17 = 128 key.F18 = 129 key.F19 = 130 key.F20 = 131 key.F21 = 132 key.F22 = 133 key.F23 = 134 key.F24 = 135 key.NUMLOCK = 144 key.SCROLLLOCK = 145 key.LSHIFT = 160 key.RSHIFT = 161 key.LCONTROL = 162 key.RCONTROL = 163 key.LALT = 164 key.RALT = 165 key.BROWSER_BACK = 166 key.BROWSER_FORWARD = 167 key.BROWSER_REFRESH = 168 key.BROWSER_STOP = 169 key.BROWSER_SEARCH = 170 key.BROWSER_FAVORITES = 171 key.BROWSER_HOME = 172 key.VOLUME_MUTE = 173 key.VOLUME_DOWN = 174 key.VOLUME_UP = 175 key.MEDIA_NEXT = 176 key.MEDIA_PREV = 177 key.MEDIA_STOP = 178 key.MEDIA_PLAY = 179 key.LAUNCH_MAIL = 180 key.LAUNCH_MEDIA = 181 key.LAUNCH_APP1 = 182 key.LAUNCH_APP2 = 183 key[";"] = 186 key["="] = 187 key[","] = 188 key["-"] = 189 key["."] = 190 key["/"] = 191 key["`"] = 192 key["["] = 219 key["\\"] = 220 key["]"] = 221 key["'"] = 222
pairs(key)
will also yield these values.
key.mod.ALT key.mod.CONTROL key.mod.SHIFT key.mod.WIN key.mod.UP key.mod.DOWN
mouse.pressed(button)
key.pressed
).
mouse.move(x, y[, d[, rel]])
(x,y)
(absolute or relative), over d
seconds.
mouse.click(button[, x, y[, d[, rel]]])
(x,y)
before issuing a key press (syntax as in input.send
).
mouse.drag(button, x, y[, x2, y2[, d[, rel]]])
button
, move cursor to (x,y)
and release button. If two sets of coordinates are specified,
instantly move cursor to (x,y)
, press the button and drag to (x2,y2)
over d
seconds.
mouse.bezier(button, x0, y0, x1, y1, x2, y2[, x3, y3[, d]])
button
can be nil
to simply move the mouse.
mouse.LBUTTON = 1 mouse.RBUTTON = 2 mouse.MBUTTON = 4 mouse.XBUTTON1 = 5 mouse.XBUTTON2 = 6 mouse.WHEELLEFT = 10 mouse.WHEELRIGHT = 11 mouse.WHEELUP = 14 mouse.WHEELDOWN = 15