This repository was archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
API
Vadim Dyachenko edited this page Jun 29, 2021
·
3 revisions
Aside of supporting everything in Lua Standard Library, the tool spots a number of helper functions specific to it:
-
sleep(time_ms)
NativeSleep. -
update
You may define anfunction update()that will be called each update tick (once per 30ms or so).
-
hotkey.add(options)➜hotkey
Adds a hotkey. Options are a table with fields:-
func: function to invoke.
The function will be called when the hotkey is pressed and will receive a single table-argument with additional information about the event. -
key: key code to use.
Key codes are as per MSDN -
mods (opt.): modifier keys to require.
See MSDN for supported flags (MOD_) -
modkey (opt.): non-modifier keycode to require.
The tool will automatically bind the hotkey when the modkey is pressed and unbind when it is released.
This allows using arbitrary keys as modifiers. -
layout (opt.): keyboard layout to require.
Layout codes can be found on MSDN (e.g. 0x419 for Russian).
-
func: function to invoke.
-
hotkey:remove() or hotkey.remove(hotkey)
Unbinds the hotkey and frees up the native ID for new hotkeys.
Hotkeys will be cleaned up automatically when application quits. -
hotkey:getenabled()➜enabled?
Hotkeys are enabled by default and can be disabled to deactivate them without having to re-create them. -
hotkey:setenabled(enable)
Enables or disables the given hotkey. -
hotkey:getactive()➜active?
Returns whether the given hotkey is currently active (read: can be triggered).
This will returnfalseif the hotkey's modkey is not pressed, if the keyboard layout doesn't match, or if it has been disabled.
Example:
hotkey.add({
name = "Back",
mods = MOD_ALT,
key = VK_Q,
func = function()
send.keys(VK_MENU, VK_LEFT)
end
})Convenience functions for key/text entry.
-
send.keys(...keycodes)
Presses-releases a combination of specified keys.
This is equivalent to calling keyboard.press and then keyboard.release. -
send.char(...charcodes)
Presses-releases one or more character keys (
KEYEVENTF_UNICODE).
This is necessary if you want to enter characters that cannot be typed on the current layout. -
send.text(string, delay_ms=5)
Types a string of characters with given delay between the key presses.
-
keyboard.check(keycode)➜pressed?
Returns whether the given key is currently held down.
You can find key codes on MSDN.
For your convenience, all of the constants from the said page are exposed, along with makeshift constants for letters and digit-row keys (VK_S,VK_9) -
keyboard.press(...keycodes)
Presses the given keys (key codes as per above). -
keyboard.release(...keycodes)
Releases the given keys (key codes as per above). -
keyboard.getlayout()➜HKL
Returns the keyboard layout for the current foreground window, as perGetKeyboardLayout.
-
mouse.getpos()➜x,y
Returns the current mouse position (screen coordinates). -
mouse.setpos(x,y)➜ok?
Changes the mouse position. -
mouse.check(button)➜pressed?
Returns whether the given mouse button is currently held down.
Supported buttons are 1 (left), 2 (right), 3 (middle), 4 (X1), 5 (X2). -
mouse.press(button)
Presses the given mouse button (indexes same as above) -
mouse.release(button)
Releases the given mouse button (indexes same as above) -
mouse.scroll(amount, horizontal=false)
Sends a mouse wheel event. Default is vertical scroll.
Amount is in lines (WHEEL_DELTA) and can be fractional.
These functions allow you to mute/unmute your Communications microphone!
-
micmute.get()➜muted?
Returns whether the microphone is currently muted, ornilif the status could not be determined. -
micmute.set(mute)➜muted?
Mutes/unmutes the microphone. Returns new status ornilif operation failed. -
micmute.toggles()➜muted?
Toggles microphone mute status. Returns new status ornilif operation failed.
Allows you to manipulate the application's little icon seen in the tray area.
-
trayicon.loadicon(path)➜HICON
Loads an ICO file from a specified path.
Path can be relative to the script.
The icon will be automatically disposed once there are no more references left to it. -
trayicon.seticon(HICON)➜ok?
Changes the tray icon to the specified one. -
trayicon.settext(text)➜ok?
Changes mouseover text for the tray icon.