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

Method MouseClickClicks the mouse button at the specified screen location.
Method MouseDblClickDouble-clicks the mouse button at the specified screen location.
Method DragAndDropPresses the mouse in one location and releases it in another.
Method PressKeyPresses and releases the specified keyboard key.
Method PressNKeysPresses the specified keyboard key a specified number of times.
Method MouseDownPresses the mouse button at the specified screen location.

Method MouseMove

Moves the mouse pointer to the specified screen location.
Method MouseUpReleases the mouse button at the specified screen location.
Method KeyDownReleases the mouse button at the specified screen location.
Method KeyUpReleases the specified keyboard key.
Method SendStringTypes a string.

Back to top

 

MouseClick Method

Description

Clicks the mouse button at the specified screen location.

Syntax

object.MouseClick x, y, [Button]

Arguments

ParameterDescription
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.
The mouse button used to click the object.

Possible values:

0 = LEFT_MOUSE_BUTTON (Default)

1 = MIDDLE_MOUSE_BUTTON

2 = RIGHT_MOUSE_BUTTON

Return Type

None

Example

Back to top

 

MouseDblClick Method

Description

Double-clicks the mouse button at the specified screen location.

Syntax

object.MouseDblClick x, y, [Button]

Arguments

ParameterDescription
xAn 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.
The mouse button used to click the object.

Possible values:

0 = LEFT_MOUSE_BUTTON (Default)

1 = MIDDLE_MOUSE_BUTTON

2 = RIGHT_MOUSE_BUTTON

Return Type

None

Example

Back to top

 

Method

Description

Presses the mouse in one location and releases it in another.

Syntax

object.DragAndDrop  DragX, DragY, DropX, DropY, [Button]

Arguments

ParameterDescription
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. 
DropXAn 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.
The mouse button used to drag and drop the object.

Possible values:

0 = LEFT_MOUSE_BUTTON (Default)

1 = MIDDLE_MOUSE_BUTTON

2 = RIGHT_MOUSE_BUTTON

Return Type

None

Back to top

 

PressKey Method

Description

Presses and releases the specified keyboard key.

Syntax

object.PressKey Key

Arguments

ParameterDescription
KeyA numeric value.
The decimal value of the key's IBM Scan Code. See Key Values.

Return Type

None

Example

Back to top

 

PressNKeys Method

Description

Presses the specified keyboard key a specified number of times.

Syntax

object.PressNKeys Key, N

Arguments

ParameterDescription
KeyA numeric value.
The decimal value of the key's IBM Scan Code. See Key Values.
N

A numeric value.
The number of times to press the key.

Return Type

None

Back to top

 

MouseDown Method

Description

Presses the mouse button at the specified screen location.

Syntax

object.MouseDown x, y, [Button]

Arguments

ParameterDescription
x An integer value.
The x-coordinate of the location, relative to the top left corner of the screen. 
yAn integer value.
The y-coordinate of the location, relative to the top left corner of the screen. 
Button

Optional. A predefined constant or number.
The mouse button to use for the drag and drop operation.

Possible values:

0 = LEFT_MOUSE_BUTTON (Default)

1 = MIDDLE_MOUSE_BUTTON

2 = RIGHT_MOUSE_BUTTON

Return Type

None

Example

Back to top

MouseMove Method

Description

Moves the mouse pointer to the specified screen location.

Syntax

object.MouseMove x, y

Arguments

ParameterDescription
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

Back to top

MouseUp

Description

Releases the mouse button at the specified screen location.

Syntax

object.MouseUp x, y, [Button]

Arguments

ParameterDescription
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.

The mouse button to release.

Possible values:

0 = LEFT_MOUSE_BUTTON (Default)

1 = MIDDLE_MOUSE_BUTTON

2 = RIGHT_MOUSE_BUTTON

Return Type

None

Example

Back to top

 

KeyDown Method

Description

Releases the mouse button at the specified screen location.

Syntax

object.KeyDown Key

Arguments

ParameterDescription
KeyA numeric value.
The decimal value of the key's IBM Scan Code. See Key Values.

Return Type

None

Example

Back to top

KeyUp Method

Description

Releases the specified keyboard key.

Syntax

object.KeyUp Key

Arguments

ParameterDescription
KeyA numeric value.
The decimal value of the key's IBM Scan Code. See Key Values.

Return Type

None

Example

Back to top

SendString Method

Description

Types a string.

Syntax

object.SendString wStr

Arguments

ParameterDescription
wStrA String value.
The string to type.

Return Type

None

Back to top

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.

KeyValueKeyValue
A30

`

41

B48-12
C46=13
D32\

43

E18

BKSP

14
F33TAB15
G34L SHFT

42

H35L CTRL29
I23L ALT56
J36R SHFT54
K37

R CTRL

157

L38R ALT184
M50ENTER 28
N49ESC 1
O24

SCROLL

70
P25[

26

Q16]27
R19INSERT 210
S31HOME 199
T20PG UP201
U22DELETE 211
V47END 207
W17PG DN209
X45

U ARROW

200
Y21L ARROW203
Z44D ARROW208
011R ARROW205
12

;

39
23'40
34,51
45.52
56/53
67

Keypad /

181
78

Keypad *

55
89

Keypad -

74
910

Keypad +

78
SPACE57

Keypad EN

156

CAPS

58

Keypad .

83
F159

Keypad 0

82
F260Keypad 179
F361Keypad 280
F462Keypad 381
F563Keypad 475
F664Keypad 576
F765Keypad 677
F866Keypad 771
F967Keypad 872
F1068Keypad 973
F1187  
F1288  

NUM

69  

See also: