Events

class macpy.event.Event

Base class for all macpy events.

time

Event timestamp. This does not translate to concrete time but timestamps of later events are guaranteed to be greater than timestamps of earlier events.

Type:float

Pointer

class macpy.event.PointerEventMotion(x, y, modifiers)

Event representing pointer movement on screen.

position

A namedtuple containing x and y coordinates of pointer on screen.

Type:tuple
modifiers

A namedtuple containing modifier state at the time of this event.

Type:tuple
__init__(x, y, modifiers)

Event representing pointer motion.

Parameters:
  • x (int) – Pointer position on x axis in pixels.
  • y (int) – Pointer position on y axis in pixels.
  • modifiers (dict) – Modifier key state at the time of this event.
class macpy.event.PointerEventButton(x, y, button, state, modifiers)

Event representing button events on connected pointing devices.

button

Button that was pressed/released.

Type:Key
state

Whether button was pressed or released.

Type:KeyState
modifiers

A namedtuple containing modifier state at the time of this event.

Type:tuple
__init__(x, y, button, state, modifiers)

Event representing button press/release.

Parameters:
  • x (int) – Pointer position on x axis in pixels.
  • y (int) – Pointer position on y axis in pixels.
  • button (Key) – Button that was pressed/released.
  • state (KeyState) – Whether the button was pressed or released.
  • modifiers (dict) – Modifier key state at the time of this event.
class macpy.event.PointerEventAxis(x, y, value, axis, modifiers)

Event representing scrolling.

value

The amount scrolled. This is platform dependent.

Type:float
axis

The axis along which scrolling ocured.

Type:PointerAxis
modifiers

A namedtuple containing modifier state at the time of this event.

Type:tuple
__init__(x, y, value, axis, modifiers)

Event representing scrolling.

Parameters:
  • x (int) – Pointer position on x axis in pixels.
  • y (int) – Pointer position on y axis in pixels.
  • value (int) – The amount scrolled, exact interpretation of this value is platform-specific.
  • axis (PointerAxis) – The axis along which to scroll.
  • modifiers (dict) – Modifier key state at the time of this event.

Keyboard

class macpy.event.KeyboardEvent(key, state, char, modifiers, locks)

Event representing key press/release on connected keyboards.

key

The key that was pressed/released.

Type:Key
state

Whether the key was pressed or released.

Type:KeyState
char

The character produced by this key event if any.

Type:str
modifiers

A namedtuple containing modifier state at the time of this event.

Type:tuple
locks

A namedtuple containing lock key state at the time of this event.

Type:tuple
__init__(key, state, char, modifiers, locks)

Event representing key press/release.

Parameters:
  • key (Key) – The key that will be pressed/released.
  • state (KeyState) – Whether the key will be pressed or released.
  • char (str) – The character that will be typed. Currently this is ignored, you can set it to None.
  • modifiers (dict) – Modifier key state at the time of this event.
  • locks (dict) – Lock key state at the time of this event.
class macpy.event.HotKey(key, modifiers)

A hotkey object.

Hotkey object are hashable and compare equal regardless of timestamps.

key

A key that triggered this event.

Type:Key
modifiers

A frozenset of modifier keys that were also pressed.

Type:frozenset
class macpy.event.HotString(string, triggers, trigger=None)

A hotstring object.

Hotstring objects are hashable and compare equal regardless of timestamps and the current trigger.

string

The string that needs to be typed to trigger this hotstring.

Type:str
triggers

The trigger keys that need to be typed after the string. This frozenset may be empty.

Type:frozenset
trigger

The trigger that triggered this hotstring. May be None.

Type:str

Window

class macpy.event.WindowEvent(window, event_type)

Event representing window creation, destruction and focus change.

window

The window that was created/destroyed/focused.

Type:Window
type

The action that was taken on the window.

Type:WindowEventType