QTP Script to send Keyboard Input to an Application

Share This Post -
Sending Keyboard Input to an Application
The example below uses the PressKey method to send keyboard input to an application.

'An example that presses a key using DeviceReplay.

Set obj = CreateObject("Mercury.DeviceReplay")

Window("Notepad").Activate

obj.PressKey 63

The PressKey method uses the ASCII value for the key.
63 is the ASCII value for F5.

ASCII values for other keys:
F1 - 59
F2 - 60
F3 - 61
F4 - 62
F5 - 63
F6 - 64
F7 - 65
F8 - 66
F9 - 67
F10 - 68
F11 - 87
F12 - 88