.. wxPython Phoenix documentation This file was generated by Phoenix's sphinx generator and associated tools, do not edit by hand. Copyright: (c) 2011-2020 by Total Control Software License: wxWindows License .. include:: headings.inc .. _wx.UIActionSimulator: ========================================================================================================================================== |phoenix_title| **wx.UIActionSimulator** ========================================================================================================================================== :ref:`wx.UIActionSimulator` is a class used to simulate user interface actions such as a mouse click or a key press. Common usage 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 :ref:`UIActionSimulator Sample ` for an example of using this class. .. versionadded:: 2.9.2 | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class UIActionSimulator:
| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~wx.UIActionSimulator.__init__` Default constructor. :meth:`~wx.UIActionSimulator.Char` Press and release a key. :meth:`~wx.UIActionSimulator.KeyDown` Press a key. :meth:`~wx.UIActionSimulator.KeyUp` Release a key. :meth:`~wx.UIActionSimulator.MouseClick` Click a mouse button. :meth:`~wx.UIActionSimulator.MouseDblClick` Double-click a mouse button. :meth:`~wx.UIActionSimulator.MouseDown` Press a mouse button. :meth:`~wx.UIActionSimulator.MouseDragDrop` Perform a drag and drop operation. :meth:`~wx.UIActionSimulator.MouseMove` Move the mouse to the specified coordinates. :meth:`~wx.UIActionSimulator.MouseUp` Release a mouse button. :meth:`~wx.UIActionSimulator.Select` Simulate selection of an item with the given text. :meth:`~wx.UIActionSimulator.Text` Emulate typing in the keys representing the given string. ================================================================================ ================================================================================ | |api| Class API =============== .. class:: wx.UIActionSimulator(object) **Possible constructors**:: UIActionSimulator() UIActionSimulator is a class used to simulate user interface actions such as a mouse click or a key press. .. method:: __init__(self) Default constructor. .. method:: Char(self, keycode, modifiers=MOD_NONE) Press and release a key. :param `keycode`: Key to operate on, as an integer. It is interpreted as a KeyCode. :type `keycode`: int :param `modifiers`: A combination of :ref:`wx.KeyModifier` flags to be pressed with the given keycode. :type `modifiers`: int :rtype: `bool` .. method:: KeyDown(self, keycode, modifiers=MOD_NONE) Press a key. If you are using modifiers then it needs to be paired with an identical KeyUp or the modifiers will not be released (MSW and macOS). :param `keycode`: Key to operate on, as an integer. It is interpreted as a KeyCode. :type `keycode`: int :param `modifiers`: A combination of :ref:`wx.KeyModifier` flags to be pressed with the given keycode. :type `modifiers`: int :rtype: `bool` .. method:: KeyUp(self, keycode, modifiers=MOD_NONE) Release a key. :param `keycode`: Key to operate on, as an integer. It is interpreted as a KeyCode. :type `keycode`: int :param `modifiers`: A combination of :ref:`wx.KeyModifier` flags to be pressed with the given keycode. :type `modifiers`: int :rtype: `bool` .. method:: MouseClick(self, button=MOUSE_BTN_LEFT) Click a mouse button. :param `button`: Button to press. See :meth:`wx.UIActionSimulator.MouseDown` for a list of valid constants. :type `button`: int :rtype: `bool` .. method:: MouseDblClick(self, button=MOUSE_BTN_LEFT) Double-click a mouse button. :param `button`: Button to press. See :meth:`wx.UIActionSimulator.MouseDown` for a list of valid constants. :type `button`: int :rtype: `bool` .. method:: MouseDown(self, button=MOUSE_BTN_LEFT) Press a mouse button. :param `button`: Button to press. Valid constants are ``MOUSE_BTN_LEFT`` , ``MOUSE_BTN_MIDDLE`` , and ``MOUSE_BTN_RIGHT`` . :type `button`: int :rtype: `bool` .. method:: MouseDragDrop(self, x1, y1, x2, y2, button=MOUSE_BTN_LEFT) Perform a drag and drop operation. :param `x1`: x start coordinate, in screen coordinates. :type `x1`: long :param `y1`: y start coordinate, in screen coordinates. :type `y1`: long :param `x2`: x destination coordinate, in screen coordinates. :type `x2`: long :param `y2`: y destination coordinate, in screen coordinates. :type `y2`: long :param `button`: Button to press. See :meth:`wx.UIActionSimulator.MouseDown` for a list of valid constants. :type `button`: int :rtype: `bool` .. method:: MouseMove(self, *args, **kw) |overload| Overloaded Implementations: :html:`

` **MouseMove** `(self, x, y)` Move the mouse to the specified coordinates. :param `x`: x coordinate to move to, in screen coordinates. :type `x`: long :param `y`: y coordinate to move to, in screen coordinates. :type `y`: long :rtype: `bool` :html:`

` **MouseMove** `(self, point)` Move the mouse to the specified coordinates. :param `point`: Point to move to, in screen coordinates. :type `point`: wx.Point :rtype: `bool` :html:`

` .. method:: MouseUp(self, button=MOUSE_BTN_LEFT) Release a mouse button. :param `button`: Button to press. See :meth:`wx.UIActionSimulator.MouseDown` for a list of valid constants. :type `button`: int :rtype: `bool` .. method:: Select(self, text) Simulate selection of an item with the given text. This method selects an item in the currently focused :ref:`wx.Choice`, :ref:`wx.ComboBox`, :ref:`wx.ListBox` and similar controls. It does it by simulating keyboard events, so the behaviour should be the same as if the item was really selected by the user. Notice that the implementation of this method uses `wx.Yield` and so events can be dispatched from it. :param `text`: The text of the item to select. :type `text`: string :rtype: `bool` :returns: ``True`` if the item `text` was successfully selected or ``False`` if the currently focused window is not one of the controls allowing item selection or if the item with the given text was not found in it. .. versionadded:: 4.1/wxWidgets-3.1.0 .. method:: Text(self, text) Emulate typing in the keys representing the given string. Currently only the ``ASCII`` letters are universally supported. Digits and punctuation characters can be used with the standard ``QWERTY`` (``US``) keyboard layout but may not work with other layouts. :param `text`: The string, containing only ``US`` ``ASCII`` characters, to type. :type `text`: int :rtype: `bool`