Public Types | Static Public Member Functions

CxUtils::Mouse Class Reference

Static methods for determining the current position of the mouse cursor on the screen and to emulate mouse movements and button clicks. More...

#include <mouse.h>

List of all members.

Public Types

enum  Button {
  Any = -1, Invalid = 0, LeftButton = 0x01, RightButton = 0x02,
  MiddleButton = 0x04
}
 

Button values on a mouse.

More...

Static Public Member Functions

static bool IsButtonDown (const Button button=Any)
 Checks if button on the mouse is being pressed/clicked.
static Button GetCurrentButton ()
 Gets the current button being pressed.
static bool FakeButtonPress (const Button button, const bool releaseFlag=true)
 Method used to fake a mouse button press.
static bool FakeButtonRelease (const Button button)
 Method used to fake a mouse button release.
static bool SetCursorPosition (const double dx, const double dy, const bool absoluteFlag=true)
 Sets the mouse cursor to an absolute position or moves it by a number of pixels relative to current position.
static bool GetCursorPosition (double &x, double &y, const bool normalized=true)
 Gets the current position of the mouse cursor.
static bool GetScreenResolution (unsigned int &width, unsigned int &height)
 Gets the current screen resolution.

Detailed Description

Static methods for determining the current position of the mouse cursor on the screen and to emulate mouse movements and button clicks.

Dependencies for Linux: libx11, libxtst

Definition at line 58 of file mouse.h.


Member Enumeration Documentation

Button values on a mouse.

Enumerator:
Any 
Invalid 
LeftButton 
RightButton 
MiddleButton 

Definition at line 67 of file mouse.h.


Member Function Documentation

bool Mouse::FakeButtonPress ( const Button  button,
const bool  releaseFlag = true 
) [static]

Method used to fake a mouse button press.

Parameters:
[in]buttonThe mouse button to simulate a click for.
[in]releaseFlagIf true, the method will also generate a key up command after the key down event.
Returns:
True on success, false on failure.

Definition at line 188 of file mouse.cpp.

bool Mouse::FakeButtonRelease ( const Button  button ) [static]

Method used to fake a mouse button release.

Parameters:
[in]buttonThe mouse button to simulate a release for.
Returns:
True on success, false on failure.

Definition at line 267 of file mouse.cpp.

Mouse::Button Mouse::GetCurrentButton (  ) [static]

Gets the current button being pressed.

Returns:
The value of the current button that is down.

Definition at line 125 of file mouse.cpp.

bool Mouse::GetCursorPosition ( double &  x,
double &  y,
const bool  normalized = true 
) [static]

Gets the current position of the mouse cursor.

Parameters:
[out]xThe x position of the cursor. 0 is the left side increasing positive to the right.
[out]yThe y position of the cursor. 0 is the top of the screen increasing as you go down.
[in]normalizedIf true, then the values of x and y are normalized to [0,1]. If false, the values are in screen pixels.
Returns:
True on success, false on failure.

Definition at line 416 of file mouse.cpp.

bool Mouse::GetScreenResolution ( unsigned int &  width,
unsigned int &  height 
) [static]

Gets the current screen resolution.

Parameters:
[out]widthScreen width in pixels.
[out]heightScreen height in pixels.
Returns:
True on success, false on failure.

Definition at line 480 of file mouse.cpp.

bool Mouse::IsButtonDown ( const Button  button = Any ) [static]

Checks if button on the mouse is being pressed/clicked.

Parameters:
[in]buttonThe mouse button to check if it is clicked.
Returns:
True if the button is currently down.

Definition at line 63 of file mouse.cpp.

bool Mouse::SetCursorPosition ( const double  dx,
const double  dy,
const bool  absoluteFlag = true 
) [static]

Sets the mouse cursor to an absolute position or moves it by a number of pixels relative to current position.

Parameters:
[in]dxThe x position of the cursor normalized to [0,1] or the number of pixels the mouse has moved to the left or right. Positive relative movements are to the right, negative to the left.
[in]dyThe y position of the cursor normalized to [0,1] or the number of pixels the mouse has moved up or down. A positive value is a movement down.
[in]absoluteFlagIf true, dx and dy are absolute positions on the screen to move the mouse. If false, then dx an dy are relative movements in pixels.
Returns:
True on success, false on failure.

Definition at line 347 of file mouse.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines