Press Enter Key in qtp

Sam picture Sam · Aug 25, 2010 · Viewed 40.6k times · Source

How to perform the Pressing of Enter Action in QTP. I'm selecting a cell and able to set a value ,now I want to press enter key and get the list from that Java Edit box. Which are the different ways I can achieve this?

Answer

katmoon picture katmoon · Aug 29, 2010
  1. Use mentioned above Type method: YourObject.Type micReturn

  2. Use SendKeys method:

    Function SendKeys(sKey)

    Set WshShell = CreateObject("WScript.Shell")

    WshShell.AppActivate "Your browser" ' You may need to activate your browser first

    WshShell.SendKeys sKey

    wait(1) ' You may need to add some Wait statements around

    End Function

In your case it will be

SendKeys "{ENTER}"

See MSDN SendKeys and MSDN AppActivate for more details.