Questions tagged [cgeventtap]
79 questions
2
votes
0 answers
Distinguish Magic mouse/Trackpad scroll event
Inside an Event Tap I need to distinguish the scroll event that comes from a magic mouse to that which comes from a TrackPad.
Does anyone have a solution to this problem? Is there a way to get the product ID of the generating device from the…

tarmes
- 15,366
- 10
- 53
- 87
2
votes
1 answer
Can't simulate backspace button on some applications with event tap
I'm trying to simulate some key presses on Mac OS. This code is supposed to delete one previous character if the 'h' key is pressed (e.g. if user types 'tigh' it will become 'ti') by modifying keyboard events. However it only works with some…

fang
- 617
- 6
- 17
2
votes
1 answer
Segmentation Fault 11 | CGEventTap application stops processing mouse events after arbitrary amount of time.
The purpose of this application is to run in the background 24/7 and lock the mouse in the center of the screen. It's for work with a series of flash programs to simulate joystick-style movement for the mouse. I've already attempted to use other…

BumbleShrimp
- 2,150
- 23
- 42
1
vote
0 answers
How to post to event to specific window on MacOS?
I am trying to post a command + mouse drag event to a specific window.
Create an NSEvent
Post the underline cgevent
It does not work whether with postToPid or post. What I want to achieve is that: there are maybe multiple window at the same…

chunyang.wen
- 204
- 1
- 9
1
vote
1 answer
What user input can cause kCGEventTapDisabledByUserInput
CG Event taps can be disabled by user input, in which case they receive an event of type kCGEventTapDisabledByUserInput. But what user input would that be? What's the magic key chord to disable event taps?

Lawrence D'Anna
- 2,998
- 2
- 22
- 25
1
vote
1 answer
Determine if trackpad exists on macOS
Is there an API in AppKit (or elsewhere) to determine if a device has a trackpad connected and enabled? I need my application to enable different behaviours on scroll events depending on whether they are coming from a two finger natural scroll…

Savvas Dalkitsis
- 11,476
- 16
- 65
- 104
1
vote
1 answer
Automatically allow app (built & run by Xcode) to control your computer
I am developing an assistive MacOS app in Xcode / ObjC.
It intercepts keystrokes using event-taps.
When I run it from Xcode, I get:
2019-07-05 06:20:32.423783+0300 mapper[8108:1191874] unable to create event tap. must run as root or add privileges…

P i
- 29,020
- 36
- 159
- 267
1
vote
0 answers
How to consume CAPS-LOCK event on MacOS
I am trying to remap CAPS-LOCK.
I can successfully detect CAPS-LOCK key-down/up events using CGEventTap.
However, I am unable to consume them. (OTOH I am able to consume ordinary key-down/up events).
The below code excerpt illustrates…

P i
- 29,020
- 36
- 159
- 267
1
vote
0 answers
Programmatically disable "Shake to find pointer" MacOS feature without hiding cursor
I am aware of this question, but that's different to what I am looking for, as the accepted answer hides the cursor.
I'm writing software that remaps the left mouse button to the left CTRL key.
I have it working, with one problem: when I hold down…

P i
- 29,020
- 36
- 159
- 267
1
vote
1 answer
How do I process a mouse click using Quartz events?
I have a CGEventTap and I would like to observe and process all system mouse click events. Detecting a mouse click event is easy, but I don’t want some of the clicks to get processed by the rest of the system. And I can’t figure out how.
The system…

zoul
- 102,279
- 44
- 260
- 354
1
vote
1 answer
How to post a Quartz Event after Swift application launch?
I am writing a simple Cocoa app that will be launched from AppleScript just to post a Quartz Event to another app.
There is no need for a user interface so I deleted the window from the Interface Builder and the outlet to it from the Application…

Wojciech
- 63
- 9
1
vote
1 answer
How to create a scroll wheel event that scrolls diagonally?
The docs are really stingy regarding this but from the info I gathered online, the wheelCount should be 1 for Y-only, 2 for Y-X, 3 for Y-X-Z.
To my understanding setting wheelCount = 2 inside CGEventCreateScrollWheelEvent should scroll both x and y…

Segev
- 19,035
- 12
- 80
- 152
1
vote
0 answers
How to Convert CGEvent to NSEvent in Swift?
I'm trying to convert CGEvent to NSEvent using NSEvent(cgEvent: event) in order to get the characters of key press, but I get the error saying it's an "Invalid event." My code and the error message are below. Any help would b eappreciated.…

jl303
- 1,461
- 15
- 27
1
vote
1 answer
Parsing Keyboard Shortcuts from CGEvent
I'm trying to parse a CGEvent from myCGEventCallback for keyboard events. I can get access to modifier flags, keycode, UniChar.
So far I managed to get it to work for some combinations like command+shift+f, but I have a couple of problems for some…

jl303
- 1,461
- 15
- 27
1
vote
0 answers
detect when use allow the application to use universal access
I am developing an utility for OSX which need to use Universal Access (accessibility and event tap).
I am using AXIsProcessTrustedWithOptions to check if the application is allowed. I am checking this state every second (pooling) in order to detect…

AP.
- 5,205
- 7
- 50
- 94