CGPostMouseEvent
Synthesizes a low-level mouse-button event on the local machine.
Declaration
extern 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
trueif the on-screen cursor should be moved to the location specified in themouseCursorPositionparameter; otherwise, passfalse.- buttonCount
The number of mouse buttons, up to a maximum of 32.
- mouseButtonDown
Pass
trueto specify that the primary or left mouse button is down; otherwise, passfalse.- …
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.
Returns
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 init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:), which allows you to create a mouse event and customize the event before posting it to the event system.
See Also
Functions
CGAcquireDisplayFadeReservation(_:_:)CGAssociateMouseAndMouseCursorPosition(_:)CGBeginDisplayConfiguration(_:)CGCancelDisplayConfiguration(_:)CGCaptureAllDisplays()CGCaptureAllDisplaysWithOptions(_:)CGColorConversionInfoCreateFromListCGCompleteDisplayConfiguration(_:_:)CGConfigureDisplayFadeEffect(_:_:_:_:_:_:)CGConfigureDisplayMirrorOfDisplay(_:_:_:)CGConfigureDisplayMode(_:_:_:)CGConfigureDisplayOrigin(_:_:_:_:)CGConfigureDisplayStereoOperation(_:_:_:_:)CGConfigureDisplayWithDisplayMode(_:_:_:_:)CGContextDrawPDFDocument