Create, modify and inspect events for hs.eventtap
This module is based primarily on code from the previous incarnation of Mjolnir by Steven Degutis.
Signature | hs.eventtap.event.properties -> table |
---|---|
Type | Constant |
Description | A table containing property types for use with The constants defined in this table are as follows: (I) in the description indicates that this property is returned or set as an integer (N) in the description indicates that this property is returned or set as a number (floating point)
Notes:
|
Signature | hs.eventtap.event.rawFlagMasks[] |
---|---|
Type | Constant |
Description | A table containing key-value pairs describing the raw modifier flags which can be manipulated with hs.eventtap.event:rawFlags. This table and hs.eventtap.event:rawFlags are both considered experimental as the full meanings behind some of these flags and what combinations are likely to be observed is still being determined. It is possible that some of these key names may change in the future. At present, what is known about the flags is presented here:
The following are also defined in IOLLEvent.h, but the description is a guess since I have not observed them myself
It has also been observed that synthetic events that have been posted also have the bit represented by 0x20000000 set. This constant does not appear in IOLLEvent.h or CGEventTypes.h, which defines most of the constants used in this module, so it is not included within this table at present, but may be added in the future if any corroborating information can be found. For what it may be worth, I have found it most useful to filter out Any documentation or references that can be found which can further expand on the information here is welcome -- Please submit any information you may have through the Hammerspoon GitHub site or Google group. |
Signature | hs.eventtap.event.types -> table |
---|---|
Type | Constant |
Description | A table containing event types to be used with The constants defined in this table are as follows:
Notes:
|
Signature | hs.eventtap.event.newKeyEventSequence(modifiers, character) -> table |
---|---|
Type | Function |
Description | Generates a table containing the keydown and keyup events to generate the keystroke with the specified modifiers. Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:copy() -> event |
---|---|
Type | Constructor |
Description | Duplicates an Parameters:
Returns:
|
Signature | hs.eventtap.event.newEvent() -> event |
---|---|
Type | Constructor |
Description | Creates a blank event. You will need to set its type with hs.eventtap.event:setType Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event.newEventFromData(data) -> event |
---|---|
Type | Constructor |
Description | Creates an event from the data encoded in the string provided. Parameters:
Returns:
|
Signature | hs.eventtap.event.newKeyEvent([mods], key, isdown) -> event |
---|---|
Type | Constructor |
Description | Creates a keyboard event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event.newMouseEvent(eventtype, point[, modifiers) -> event |
---|---|
Type | Constructor |
Description | Creates a new mouse event Parameters:
Returns:
|
Signature | hs.eventtap.event.newScrollEvent(offsets, mods, unit) -> event |
---|---|
Type | Constructor |
Description | Creates a scroll wheel event Parameters:
Returns:
|
Signature | hs.eventtap.event.newSystemKeyEvent(key, isdown) -> event |
---|---|
Type | Constructor |
Description | Creates a keyboard event for special keys (e.g. media playback) Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:asData() -> string |
---|---|
Type | Method |
Description | Returns a string containing binary data representing the event. This can be used to record events for later use. Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getButtonState(button) -> bool |
---|---|
Type | Method |
Description | Gets the state of a mouse button in the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getCharacters([clean]) -> string or nil |
---|---|
Type | Method |
Description | Returns the Unicode character, if any, represented by a keyDown or keyUp event. Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getFlags() -> table |
---|---|
Type | Method |
Description | Gets the keyboard modifiers of an event Parameters:
Returns:
|
Signature | hs.eventtap.event:getKeyCode() -> keycode |
---|---|
Type | Method |
Description | Gets the raw keycode for the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getProperty(prop) -> number |
---|---|
Type | Method |
Description | Gets a property of the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getRawEventData() -> table |
---|---|
Type | Method |
Description | Returns raw data about the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:getType() -> number |
---|---|
Type | Method |
Description | Gets the type of the event Parameters:
Returns:
|
Signature | hs.eventtap.event:location([pointTable]) -> event | table |
---|---|
Type | Method |
Description | Get or set the current mouse pointer location as defined for the event. Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:post([app]) |
---|---|
Type | Method |
Description | Posts the event to the OS - i.e. emits the keyboard/mouse input defined by the event Parameters:
Returns:
|
Signature | hs.eventtap.event:rawFlags([flags]) -> event | integer |
---|---|
Type | Method |
Description | Experimental method to get or set the modifier flags for an event directly. Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:setFlags(table) -> event |
---|---|
Type | Method |
Description | Sets the keyboard modifiers of an event Parameters:
Returns:
|
Signature | hs.eventtap.event:setKeyCode(keycode) |
---|---|
Type | Method |
Description | Sets the raw keycode for the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:setProperty(prop, value) |
---|---|
Type | Method |
Description | Sets a property of the event Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:setType(type) -> event |
---|---|
Type | Method |
Description | Set the type for this event. Parameters:
Returns:
|
Signature | hs.eventtap.event:systemKey() -> table |
---|---|
Type | Method |
Description | Returns the special key and its state if the event is a NSSystemDefined event of subtype AUX_CONTROL_BUTTONS (special-key pressed) Parameters:
Returns:
Notes:
|
Signature | hs.eventtap.event:timestamp([absolutetime]) -> event | integer |
---|---|
Type | Method |
Description | Get or set the timestamp of the event. Parameters:
Returns:
Notes:
|