.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 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 <uiactionsimulator sample>`  for an example of using this class. 







.. versionadded:: 2.9.2 
    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>UIActionSimulator</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.UIActionSimulator_inheritance.png" alt="Inheritance diagram of UIActionSimulator" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.UIActionSimulator.html" title="wx.UIActionSimulator" alt="" coords="5,5,168,35"/> </map> 
   </p>
   </div>

|


|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.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 OSX). 




      :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:`<hr class="overloadsep" /><br />`

      
      **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:`<hr class="overloadsep" /><br />`

      
      **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:`<hr class="overloadsep" /><br />`






   .. 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:: Text(self, text)

      Emulate typing in the keys representing the given string.                  

      Currently only the ``ASCII`` letters, digits and characters for the definition of numbers (i.e. characters  ``a-z``       ``A-Z``       ``0-9``       ``+``       ``-``       ``'space'`` ) are supported. 




      :param `text`: The string to type.   
      :type `text`: string






      :rtype: `bool`



                  




