1. 0 2.0

Posts a virtual mouse code to Windows.

  • oid PostVirtualMouseEvent( UINT wMouseFlags, int xPos, int yPos )



Flags indicating the type of mouse event. This can be one or more of the following values, combined by a bitwise-OR operator.

Simulates a change in the mouse cursor position. This flag can be combined with any of the other flags in this table.
Simulates pushing the left mouse button.
Simulates releasing the left mouse button.
Simulates pushing the right mouse button.
Simulates releasing the right mouse button.


The x-axis position in screen coordinates.


The y-axis position in screen coordinates.

Return Value

This function does not return a value.


The x- and y-axis positions are absolute positions in screen coordinates. Note that the x and y values should not exceed the screen-resolution limits. Values greater than the maximum resolution in the x-direction (640 for standard VGA) or the y-direction (480 for standard VGA) cause an overflow.

The events are posted to the system message queue. The application with the input focus can receive the messages by calling the Windows GetMessage or PeekMessage message.

Because of the way Windows interprets mouse messages, the calling application must be careful about the order in which events are sent to the system. A message that represents both a button-state transition and a move generates first a Windows event for the button transition at the current pointer location and then a move to the new location. To simulate a move to a new location followed by a button transition, the application must make separate calls to PostVirtualMouseEvent for each simulated event.


When posting events, the caller should bracket the calls by calls to AtomicVirtualEvent, which locks out pen packets while the application is posting simulated mouse events. For example, the following code fragment posts a mouse event:



// ... PostVirtualMouseEvent calls go here



The Windows GetMessageExtraInfo function returns 0 for any messages generated by PostVirtualMouseEvent.

See Also

, PostVirtualKeyEvent

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database