DeviceReplay Object
Description
An object used to simulate operations performed using a keyboard or mouse.
IMPORTANT
The DeviceReplay object is a UFT One reserved object. Reserved objects are not learned or stored in the object repository.
To use a DeviceReply object you need to create it using a CreateObject statement.
Set <Object Name>= CreateObject("Mercury.DeviceReplay")
When you no longer need the object in your test, release it.
Set <Object Name>= Nothing
Operations
The sections below list the built-in methods and properties that you can use as operations for the DeviceReplay object.
Methods
![]() | Clicks the mouse button at the specified screen location. |
![]() | Double-clicks the mouse button at the specified screen location. |
![]() | Presses the mouse in one location and releases it in another. |
![]() | Presses and releases the specified keyboard key. |
![]() | Presses the specified keyboard key a specified number of times. |
![]() | Presses the mouse button at the specified screen location. |
Moves the mouse pointer to the specified screen location. | |
![]() | Releases the mouse button at the specified screen location. |
![]() | Releases the mouse button at the specified screen location. |
![]() | Releases the specified keyboard key. |
![]() | Types a string. |
MouseClick Method
Description
Clicks the mouse button at the specified screen location.
Syntax
object.MouseClick x, y, [Button]
Arguments
Parameter | Description |
---|---|
x |
An integer value. The x-coordinate of the click, relative to the top left corner of the screen. |
y |
An integer value. The y-coordinate of the click, relative to the top left corner of the screen. |
Button |
Optional. A predefined constant or number. Possible values: 0 = LEFT_MOUSE_BUTTON (Default) 1 = MIDDLE_MOUSE_BUTTON 2 = RIGHT_MOUSE_BUTTON |
Return Type
None
Example
MouseDblClick Method
Description
Double-clicks the mouse button at the specified screen location.
Syntax
object.MouseDblClick x, y, [Button]
Arguments
Parameter | Description |
---|---|
x | An integer value. The x-coordinate of the double-click, relative to the top left corner of the screen. |
y |
An integer value. The y-coordinate of the double-click, relative to the top left corner of the screen. |
Button |
Optional. A predefined constant or number. Possible values: 0 = LEFT_MOUSE_BUTTON (Default) 1 = MIDDLE_MOUSE_BUTTON 2 = RIGHT_MOUSE_BUTTON |
Return Type
None
Example
Method
Description
Presses the mouse in one location and releases it in another.
Syntax
object.DragAndDrop DragX, DragY, DropX, DropY, [Button]
Arguments
Parameter | Description |
---|---|
DragX |
An integer value. The x-coordinate of the location to press the mouse, relative to the top left corner of the screen. |
DragY |
An integer value. The y-coordinate of the location to press the mouse, relative to the top left corner of the screen. |
DropX | An integer value. The x-coordinate of the location to release the mouse, relative to the top left corner of the screen. |
DropY |
An integer value. The y-coordinate of the location to release the mouse, relative to the top left corner of the screen. |
Button |
Optional. A predefined constant or number. Possible values: 0 = LEFT_MOUSE_BUTTON (Default) 1 = MIDDLE_MOUSE_BUTTON 2 = RIGHT_MOUSE_BUTTON |
Return Type
None
PressKey Method
Description
Presses and releases the specified keyboard key.
Syntax
object.PressKey Key
Arguments
Parameter | Description |
---|---|
Key | A numeric value. The decimal value of the key's IBM Scan Code. See Key Values. |
Return Type
None
Example
PressNKeys Method
Description
Presses the specified keyboard key a specified number of times.
Syntax
object.PressNKeys Key, N
Arguments
Parameter | Description |
---|---|
Key | A numeric value. The decimal value of the key's IBM Scan Code. See Key Values. |
N | A numeric value. |
Return Type
None
MouseDown Method
Description
Presses the mouse button at the specified screen location.
Syntax
object.MouseDown x, y, [Button]
Arguments
Parameter | Description |
---|---|
x |
An integer value. The x-coordinate of the location, relative to the top left corner of the screen. |
y | An integer value. The y-coordinate of the location, relative to the top left corner of the screen. |
Button |
Optional. A predefined constant or number. Possible values: 0 = LEFT_MOUSE_BUTTON (Default) 1 = MIDDLE_MOUSE_BUTTON 2 = RIGHT_MOUSE_BUTTON |
Return Type
None
Example
MouseMove Method
Description
Moves the mouse pointer to the specified screen location.
Syntax
object.MouseMove x, y
Arguments
Parameter | Description |
---|---|
x |
An integer value. The x-coordinate of the location, relative to the top left corner of the screen. |
y |
An integer value. The y-coordinate of the location, relative to the top left corner of the screen. |
Return Type
None
Example
MouseUp
Description
Releases the mouse button at the specified screen location.
Syntax
object.MouseUp x, y, [Button]
Arguments
Parameter | Description |
---|---|
x |
An integer value. The x-coordinate of the location, relative to the top left corner of the screen. |
y |
An integer value. The y-coordinate of the location, relative to the top left corner of the screen. |
Button |
Optional. A predefined constant or number. Possible values: 0 = LEFT_MOUSE_BUTTON (Default) 1 = MIDDLE_MOUSE_BUTTON 2 = RIGHT_MOUSE_BUTTON |
Return Type
None
Example
KeyDown Method
Description
Releases the mouse button at the specified screen location.
Syntax
object.KeyDown Key
Arguments
Parameter | Description |
---|---|
Key | A numeric value. The decimal value of the key's IBM Scan Code. See Key Values. |
Return Type
None
Example
KeyUp Method
Description
Releases the specified keyboard key.
Syntax
object.KeyUp Key
Arguments
Parameter | Description |
---|---|
Key | A numeric value. The decimal value of the key's IBM Scan Code. See Key Values. |
Return Type
None
Example
SendString Method
Description
Types a string.
Syntax
object.SendString wStr
Arguments
Parameter | Description |
---|---|
wStr | A String value.
The string to type.
|
Return Type
None
Key Values
For DeviceReplay operations that receive keyboard keys as arguments, use the following key values. These are the decimal values of the keys' IBM Scan Codes.
Key | Value | Key | Value |
---|---|---|---|
A | 30 | ` | 41 |
B | 48 | - | 12 |
C | 46 | = | 13 |
D | 32 | \ | 43 |
E | 18 | BKSP | 14 |
F | 33 | TAB | 15 |
G | 34 | L SHFT | 42 |
H | 35 | L CTRL | 29 |
I | 23 | L ALT | 56 |
J | 36 | R SHFT | 54 |
K | 37 | R CTRL | 157 |
L | 38 | R ALT | 184 |
M | 50 | ENTER | 28 |
N | 49 | ESC | 1 |
O | 24 | SCROLL | 70 |
P | 25 | [ | 26 |
Q | 16 | ] | 27 |
R | 19 | INSERT | 210 |
S | 31 | HOME | 199 |
T | 20 | PG UP | 201 |
U | 22 | DELETE | 211 |
V | 47 | END | 207 |
W | 17 | PG DN | 209 |
X | 45 | U ARROW | 200 |
Y | 21 | L ARROW | 203 |
Z | 44 | D ARROW | 208 |
0 | 11 | R ARROW | 205 |
1 | 2 | ; | 39 |
2 | 3 | ' | 40 |
3 | 4 | , | 51 |
4 | 5 | . | 52 |
5 | 6 | / | 53 |
6 | 7 | Keypad / | 181 |
7 | 8 | Keypad * | 55 |
8 | 9 | Keypad - | 74 |
9 | 10 | Keypad + | 78 |
SPACE | 57 | Keypad EN | 156 |
CAPS | 58 | Keypad . | 83 |
F1 | 59 | Keypad 0 | 82 |
F2 | 60 | Keypad 1 | 79 |
F3 | 61 | Keypad 2 | 80 |
F4 | 62 | Keypad 3 | 81 |
F5 | 63 | Keypad 4 | 75 |
F6 | 64 | Keypad 5 | 76 |
F7 | 65 | Keypad 6 | 77 |
F8 | 66 | Keypad 7 | 71 |
F9 | 67 | Keypad 8 | 72 |
F10 | 68 | Keypad 9 | 73 |
F11 | 87 | ||
F12 | 88 | ||
NUM | 69 |
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object