I'm trying to listen to all mouse clicks that the user makes. I need to know which window the user has clicked on (presumably by its CGWindowID). I am listening to all clicks through a CGEventTap, but now I can't find out how to get the window that was clicked. Do you know of some way to retrieve the window id from the CGEventRef object?
Plus, I know that I can get the window id, when using [NSEvent addGlobalMonitorForEventsMatchingMask] by getting [event windowNumber], but I can't use this listener, because for some reason, after the listener is set up it blocks all inputs to my own window. Maybe someone also knows, where this is coming from?
Thanks!
Pedro