uiaction.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: uiaction.h
  3. // Purpose: interface of wxUIActionSimulator
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxUIActionSimulator
  9. wxUIActionSimulator is a class used to simulate user interface actions
  10. such as a mouse click or a key press.
  11. Common usage for this class would be to provide playback and record (aka
  12. macro recording) functionality for users, or to drive unit tests by
  13. simulating user sessions.
  14. See the @ref page_samples_uiaction for an example of using this class.
  15. @since 2.9.2
  16. @library{wxcore}
  17. */
  18. class wxUIActionSimulator
  19. {
  20. public:
  21. /**
  22. Default constructor.
  23. */
  24. wxUIActionSimulator();
  25. /**
  26. Move the mouse to the specified coordinates.
  27. @param x
  28. x coordinate to move to, in screen coordinates.
  29. @param y
  30. y coordinate to move to, in screen coordinates.
  31. */
  32. bool MouseMove(long x, long y);
  33. /**
  34. Move the mouse to the specified coordinates.
  35. @param point
  36. Point to move to, in screen coordinates.
  37. */
  38. bool MouseMove(const wxPoint& point);
  39. /**
  40. Press a mouse button.
  41. @param button
  42. Button to press. Valid constants are @c wxMOUSE_BTN_LEFT,
  43. @c wxMOUSE_BTN_MIDDLE, and @c wxMOUSE_BTN_RIGHT.
  44. */
  45. bool MouseDown(int button = wxMOUSE_BTN_LEFT);
  46. /**
  47. Release a mouse button.
  48. @param button
  49. Button to press. See wxUIActionSimulator::MouseDown for a list of
  50. valid constants.
  51. */
  52. bool MouseUp(int button = wxMOUSE_BTN_LEFT);
  53. /**
  54. Click a mouse button.
  55. @param button
  56. Button to press. See wxUIActionSimulator::MouseDown for a list of
  57. valid constants.
  58. */
  59. bool MouseClick(int button = wxMOUSE_BTN_LEFT);
  60. /**
  61. Double-click a mouse button.
  62. @param button
  63. Button to press. See wxUIActionSimulator::MouseDown for a list of
  64. valid constants.
  65. */
  66. bool MouseDblClick(int button = wxMOUSE_BTN_LEFT);
  67. /**
  68. Perform a drag and drop operation.
  69. @param x1
  70. x start coordinate, in screen coordinates.
  71. @param y1
  72. y start coordinate, in screen coordinates.
  73. @param x2
  74. x destination coordinate, in screen coordinates.
  75. @param y2
  76. y destination coordinate, in screen coordinates.
  77. @param button
  78. Button to press. See wxUIActionSimulator::MouseDown for a list of
  79. valid constants.
  80. */
  81. bool MouseDragDrop(long x1, long y1, long x2, long y2,
  82. int button = wxMOUSE_BTN_LEFT);
  83. /**
  84. Press a key.
  85. If you are using modifiers then it needs to be paired with an identical
  86. KeyUp or the modifiers will not be released (MSW and OSX).
  87. @param keycode
  88. Key to operate on, as an integer. It is interpreted as a wxKeyCode.
  89. @param modifiers
  90. A combination of ::wxKeyModifier flags to be pressed with the given
  91. keycode.
  92. */
  93. bool KeyDown(int keycode, int modifiers = wxMOD_NONE);
  94. /**
  95. Release a key.
  96. @param keycode
  97. Key to operate on, as an integer. It is interpreted as a wxKeyCode.
  98. @param modifiers
  99. A combination of ::wxKeyModifier flags to be pressed with the given
  100. keycode.
  101. */
  102. bool KeyUp(int keycode, int modifiers = wxMOD_NONE);
  103. /**
  104. Press and release a key.
  105. @param keycode
  106. Key to operate on, as an integer. It is interpreted as a wxKeyCode.
  107. @param modifiers
  108. A combination of ::wxKeyModifier flags to be pressed with the given
  109. keycode.
  110. */
  111. bool Char(int keycode, int modifiers = wxMOD_NONE);
  112. /**
  113. Emulate typing in the keys representing the given string.
  114. Currently only the ASCII letters, digits and characters for the definition
  115. of numbers (i.e. characters @c a-z @c A-Z @c 0-9 @c + @c - @c . @c , @c 'space')
  116. are supported.
  117. @param text
  118. The string to type.
  119. */
  120. bool Text(const wxString& text);
  121. };