wxUIActionSimulator Class Reference

#include <wx/uiaction.h>


Detailed Description

wxUIActionSimulator is a class used to simulate user interface actions such as a mouse click or a key press.

Note:
that this class is currently experimental and disabled by default, you must set wxUSE_UIACTIONSIMULATOR to 1 in your setup.h file or use configure --enable-uiactionsim option to enable it.

Common usages for this class would be to provide playback and record (aka macro recording) functionality for users, or to drive unit tests by simulating user sessions.

See the uiaction sample for example usage of this class.

NOTE: For keyboard operations, currently you must pass the keycode of the actual key on the keyboard. To simulate, e.g. IME actions, you'd need to simulate the actual keypresses needed to active the IME, then the keypresses needed to type and select the desired character.

Library:  wxCore

Public Member Functions

 wxUIActionSimulator ()
 Constructor.
 ~wxUIActionSimulator ()
bool MouseMove (long x, long y)
 Move the mouse to the specified coordinates.
bool MouseDown (int button=wxMOUSE_BTN_LEFT)
 Press a mouse button.
bool MouseUp (int button=wxMOUSE_BTN_LEFT)
 Release a mouse button.
bool MouseClick (int button=wxMOUSE_BTN_LEFT)
 Click a mouse button.
bool MouseDblClick (int button=wxMOUSE_BTN_LEFT)
 Double-click a mouse button.
bool MouseDragDrop (long x1, long y1, long x2, long y2, int button=wxMOUSE_BTN_LEFT)
 Perform a drag and drop operation.
bool KeyDown (int keycode, bool shiftDown=false, bool cmdDown=false, bool altDown=false)
 Press a key.
bool KeyUp (int keycode, bool shiftDown=false, bool cmdDown=false, bool altDown=false)
 Release a key.
bool Char (int keycode, bool shiftDown=false, bool cmdDown=false, bool altDown=false)
 Press and release a key.

List of all members.


Constructor & Destructor Documentation

wxUIActionSimulator::wxUIActionSimulator (  ) 

Constructor.

wxUIActionSimulator::~wxUIActionSimulator (  ) 

Member Function Documentation

bool wxUIActionSimulator::Char ( int  keycode,
bool  shiftDown = false,
bool  cmdDown = false,
bool  altDown = false 
)

Press and release a key.

Parameters:
keycode key to operate on, as an integer.
shiftDown true if the shift key should be pressed, false otherwise.
cmdDown true if the cmd key should be pressed, false otherwise.
altDown true if the alt key should be pressed, false otherwise.
bool wxUIActionSimulator::KeyDown ( int  keycode,
bool  shiftDown = false,
bool  cmdDown = false,
bool  altDown = false 
)

Press a key.

Parameters:
keycode key to operate on, as an integer.
shiftDown true if the shift key should be pressed, false otherwise.
cmdDown true if the cmd key should be pressed, false otherwise.
altDown true if the alt key should be pressed, false otherwise.
bool wxUIActionSimulator::KeyUp ( int  keycode,
bool  shiftDown = false,
bool  cmdDown = false,
bool  altDown = false 
)

Release a key.

Parameters:
keycode key to operate on, as an integer.
shiftDown true if the shift key should be pressed, false otherwise.
cmdDown true if the cmd key should be pressed, false otherwise.
altDown true if the alt key should be pressed, false otherwise.
bool wxUIActionSimulator::MouseClick ( int  button = wxMOUSE_BTN_LEFT  ) 

Click a mouse button.

Parameters:
button Button to press. See wxUIActionSimulator::MouseDown for a list of valid constants.
bool wxUIActionSimulator::MouseDblClick ( int  button = wxMOUSE_BTN_LEFT  ) 

Double-click a mouse button.

Parameters:
button Button to press. See wxUIActionSimulator::MouseDown for a list of valid constants.
bool wxUIActionSimulator::MouseDown ( int  button = wxMOUSE_BTN_LEFT  ) 

Press a mouse button.

Parameters:
button Button to press. Valid constants are wxMOUSE_BTN_LEFT, wxMOUSE_BTN_MIDDLE, and wxMOUSE_BTN_RIGHT.
bool wxUIActionSimulator::MouseDragDrop ( long  x1,
long  y1,
long  x2,
long  y2,
int  button = wxMOUSE_BTN_LEFT 
)

Perform a drag and drop operation.

Parameters:
x1 x start coordinate, in screen coordinates.
y1 y start coordinate, in screen coordinates.
x2 x desintation coordinate, in screen coordinates.
y2 y destination coordinate, in screen coordinates.
button Button to press. See wxUIActionSimulator::MouseDown for a list of valid constants.
bool wxUIActionSimulator::MouseMove ( long  x,
long  y 
)

Move the mouse to the specified coordinates.

Parameters:
x x coordinate to move to, in screen coordinates.
y y coordinate to move to, in screen coordinates.
bool wxUIActionSimulator::MouseUp ( int  button = wxMOUSE_BTN_LEFT  ) 

Release a mouse button.

Parameters:
button Button to press. See wxUIActionSimulator::MouseDown for a list of valid constants.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines



wxWidgets logo

[ top ]