Platforms to show: All Mac Windows Linux Cross-Platform
CGEventTapMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | CoreGraphics Events | MBS MacCF Plugin | 17.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Taps may be placed at the point where HIDSystem events enter the server, at the point where HIDSystem and remote control events enter a session, at the point where events have been annotated to flow to a specific application, or at the point where events are delivered to the application. Taps may be inserted at a specified point at the head of pre-existing filters, or appended after any pre-existing filters.
Taps may be passive event listeners, or active filters. An active filter may pass an event through unmodified, modify an event, or discard an event. When a tap is registered, it identifies the set of events to be observed with a mask, and indicates if it is a passive or active event filter. Multiple event type bitmasks may be ORed together.
Taps may only be placed at kCGHIDEventTap by a process running as the root user. An exception is raised for other users.
Taps placed at kCGHIDEventTap, kCGSessionEventTap, kCGAnnotatedSessionEventTap, or on a specific process may only receive key up and down events if access for assistive devices is enabled (Preferences Accessibility panel, Keyboard view) or the caller is enabled for assistive device access, as by AXMakeProcessTrusted. If the tap is not permitted to monitor these events when the tap is created, then the appropriate bits in the mask are cleared. If that results in an empty mask, then an exception is raised.
For MacOS 10.15 using CGEventTap to track other applications may result in a dialog asking for permissions. This may not happen if you track your own process' events.
- event GotEvent(Proxy as Ptr, type as Integer, e as CGEventMBS) as CGEventMBS
- property Enabled as Boolean
- method Constructor(tapLocation as Integer, Place as Integer, Options as Integer, EventMask as Integer, PID as Integer = -1)
- shared method available as boolean
- 24 constants
Constants
Constant | Value | Description |
---|---|---|
kCGEventTapOptionDefault | 0 |
One of the constants that specify whether a new event tap is an active filter or a passive listener.
Default, active filter. |
kCGEventTapOptionListenOnly | 1 |
One of the constants that specify whether a new event tap is an active filter or a passive listener.
Listen only. |
kCGHeadInsertEventTap | 0 |
One of the constants that specify where a new event tap is inserted into the list of active event taps.
Insert in front. |
kCGTailAppendEventTap | 1 |
One of the constants that specify where a new event tap is inserted into the list of active event taps.
Append to the tail. |
Tapping Points
Constant | Value | Description |
---|---|---|
kCGAnnotatedSessionEventTap | 2 |
At the point where events have been annotated to flow to a specific application, or at the point where events are delivered to the application. |
kCGHIDEventTap | 0 |
When HIDSystem events enter the server. |
kCGSessionEventTap | 1 |
At the point where HIDSystem and remote control events enter a session. |
Event Masks
Constant | Value | Description |
---|---|---|
kCGEventMaskFlagsChanged | 4096 |
Key flags changed, e.g. modifier keys pressed. |
kCGEventMaskForAllEvents | -1 |
Listen for all events. |
kCGEventMaskKeyDown | 1024 |
Key Down |
kCGEventMaskKeyUp | 2048 |
Key up. |
kCGEventMaskLeftMouseDown | 2 |
left mouse-down event |
kCGEventMaskLeftMouseDragged | 64 |
left mouse-dragged event |
kCGEventMaskLeftMouseUp | 4 |
left mouse-up event |
kCGEventMaskMouseMoved | 32 |
mouse-moved event |
kCGEventMaskOtherMouseDown | &h2000000 |
other mouse-down event |
kCGEventMaskOtherMouseDragged | &h8000000 |
other mouse-dragged event |
kCGEventMaskOtherMouseUp | &h4000000 |
other mouse-up event |
kCGEventMaskRightMouseDown | 8 |
right mouse-down event |
kCGEventMaskRightMouseDragged | 128 |
right mouse-dragged event |
kCGEventMaskRightMouseUp | 16 |
right mouse-up event |
kCGEventMaskScrollWheel | &h400000 |
Scroll Wheel event. |
kCGEventMaskTabletPointer | &h800000 |
Tablet pointer event. |
kCGEventMaskTabletProximity | &h1000000 |
Tablet Proximity event. |
This class has no sub classes.
Some examples using this class:
Blog Entries
Release notes
- Version 19.4
- Added PID parameter to CGEventTapMBS constructor to watch only a specific process.
- Version 17.4
- Added CGEventTapMBS class to catch events low-level on macOS.
The items on this page are in the following plugins: MBS MacCF Plugin.