In QTP below are the three ways we can send keyboard keys:
1)Using Type method
2)Using Sendkeys method
3)Using DeviceReplay object
*********************************************************************************
Send the keys using Type method:
*********************************************************************************
Window(“Notepad”).Activate
Window(“Notepad”).WinEditor(“Edit”).Type "MicTAB"
*********************************************************************************
Send the keys using Sendkeys method:
*********************************************************************************
Set WshShell= CreateObject("WScript.Shell")
WshShell.Run "notepad"
'To write the letters
WshShell.SendKeys "RealworldQTP"
'to press Tab in the keyboard
WshShell.SendKeys "{TAB}"
'To press Enter in the keyboard
WshShell.SendKeys "{ENTER}"
'To send the combination keys
WshShell.SendKeys “^c” 'here '^' represents Ctrl key in the keyboard
*******************************************************************************
Send the keys using DeviceReplay object:
*********************************************************************************
Set obj = CreateObject(“Mercury.DeviceReplay”)
Window(“Notepad”).Activate
obj.PressKey 63
Note :Here 63 represents F5(ASCII value of F5 key is 63)