Function

CGPostMouseEvent

Synthesizes a low-level mouse-button event on the local machine.

Declaration

CGError CGPostMouseEvent(CGPoint mouseCursorPosition, boolean_t updateMouseCursorPosition, CGButtonCount buttonCount, boolean_t mouseButtonDown, ...);

Parameters

mouseCursorPosition

The new coordinates of the mouse in global display space.

updateMouseCursorPosition

Pass true if the on-screen cursor should be moved to the location specified in the mouseCursorPosition parameter; otherwise, pass false.

buttonCount

The number of mouse buttons, up to a maximum of 32.

mouseButtonDown

Pass true to specify that the primary or left mouse button is down; otherwise, pass false.

...

Zero or more Boolean values that specify whether the remaining mouse buttons are down (true) or up (false). The second value, if any, should specify the state of the secondary mouse button (right). A third value would specify the state of the center button, and the remaining buttons would be in USB device order.

Return Value

A result code. See the result codes described in Quartz Display Services.

Discussion

Based on the arguments you pass to this function, the function generates the appropriate mouse-down, mouse-up, mouse-move, or mouse-drag events by comparing the new state with the current state.

This function is not recommended for general use because of undocumented special cases and undesirable side effects. The recommended replacement for this function is CGEventCreateMouseEvent, which allows you to create a mouse event and customize the event before posting it to the event system.

See Also

Deprecated Functions

CGEventGetSource

Returns a Quartz event source created from an existing Quartz event.

CGPostKeyboardEvent

Synthesizes a low-level keyboard event on the local machine.

Deprecated
CGPostScrollWheelEvent

Synthesizes a low-level scrolling event on the local machine.

Deprecated
CGEnableEventStateCombining

Enables or disables the merging of actual key and mouse state with the application-specified state in a synthetic event.

Deprecated
CGInhibitLocalEvents

Turns off local hardware events in the current session.

Deprecated
CGSetLocalEventsFilterDuringSuppressionState

Filters local hardware events from the keyboard and mouse during the short interval after a synthetic event is posted.

Deprecated
CGSetLocalEventsSuppressionInterval

Sets the time interval in seconds that local hardware events are suppressed after posting a synthetic event.

Deprecated