C

InputScriptInterface Class

The InputScriptInterface class enables you to emulate user input with a mouse or the keyboard. More...

Header: #include <InputScriptInterface>

Public Types

enum MouseButton { NoButton, LeftButton, RightButton, MiddleButton, ..., MouseButtonMask }
flags MouseButtons

Properties

Public Functions

void click(qint32 x, qint32 y)
void doubleClick(qint32 x, qint32 y)
bool ignoreDeviceRotation() const
void keyPress(QChar c)
void keyRelease(QChar c)
void mouseMove(qint32 x, qint32 y)
QPoint mousePosition() const
void mousePress(MouseButton button, qint32 x, qint32 y)
void mouseRelease(MouseButton button, qint32 x, qint32 y)
int mouseX() const
int mouseY() const
void rightClick(qint32 x, qint32 y)
void type(const QString &string)

Public Slots

void setIgnoreDeviceRotation(bool map)

Detailed Description

The InputScriptInterface class enables you to emulate user input with a mouse or the keyboard.

The InputScriptInterface class is exposed as input.

Member Type Documentation

enum InputScriptInterface::MouseButton
flags InputScriptInterface::MouseButtons

This enum type describes the mouse buttons:

ConstantValueDescription
InputScriptInterface::NoButton0x00000000The button state does not refer to any button.
InputScriptInterface::LeftButton0x00000001The left button is pressed, or an event refers to the left button. The left button may be the right button on a left-handed mouse.
InputScriptInterface::RightButton0x00000002The right button.
InputScriptInterface::MiddleButtonMidButtonThe middle button.
InputScriptInterface::XButton10x00000008The Back button.
InputScriptInterface::XButton20x00000010The Forward button.
InputScriptInterface::MouseButtonMask0x000000ffThis value corresponds to a mask of possible mouse buttons. Use it to specify that a mouse area accepts several mouse buttons.

The MouseButtons type is a typedef for QFlags<MouseButton>. It stores an OR combination of MouseButton values.

Property Documentation

ignoreDeviceRotation : bool

This property holds whether to ignore device orientation when creating mouse events or reading mouse position.

This property handles the way mouse coordinates are mapped to the device. When it is set to false, the top left corner (0, 0) corresponds to the top left corner in relation to the current device orientation.

"Position 0, 0 with ignoreDeviceRotation set to false"

When it is set to true, the top left corner always is the top left corner of the display no matter which orientation is set at the moment.

"Position 0, 0 with ignoreDeviceRotation set to true"

Access functions:

bool ignoreDeviceRotation() const
void setIgnoreDeviceRotation(bool map)

Member Function Documentation

void InputScriptInterface::click(qint32 x, qint32 y)

Creates a mouse click event by pressing down and releasing a mouse button at the position specified by x and y.

void InputScriptInterface::doubleClick(qint32 x, qint32 y)

Creates a double-click event by pressing down and releasing a mouse button twice at the position specified by x and y.

void InputScriptInterface::keyPress(QChar c)

Creates a key press event by using the key specified by c.

void InputScriptInterface::keyRelease(QChar c)

Releases the key specified by c.

void InputScriptInterface::mouseMove(qint32 x, qint32 y)

Moves the mouse to the position specified by x and y.

QPoint InputScriptInterface::mousePosition() const

Reads the x and y coordinates of the mouse position.

See also InputScriptInterface::ignoreDeviceRotation.

void InputScriptInterface::mousePress(MouseButton button, qint32 x, qint32 y)

Presses down and holds the mouse button button at the position specified by x and y.

void InputScriptInterface::mouseRelease(MouseButton button, qint32 x, qint32 y)

Releases the mouse button button at the position specified by x and y.

int InputScriptInterface::mouseX() const

Returns the x coordinate of the mouse position.

int InputScriptInterface::mouseY() const

Returns the y coordinate of the mouse position.

void InputScriptInterface::rightClick(qint32 x, qint32 y)

Creates a right button click event at the position specified by x and y.

void InputScriptInterface::type(const QString &string)

Emulates typing the string string on the keyboard.

Available under certain Qt licenses.
Find out more.