What you need to do to convince these applications that you actually generated the click is to explicitly set the "click state" field in the mouse event to 1 (by default it is 0). The following code will do this:
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 1);
It should also be set to 1 for mouse down, but using CGEventCreateMouseEvent (), not CGEventCreate (), which runs for you.
I tested this and it works in the "i" buttons on the toolbar and Spotlight search results.
(Aside, if you simulated a double click, you need to set the click state to 2 for both the mouse and the mouse for the second click event.)
Nick moore
source share