GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Testing Tools  >  QTP

 Print  |  
Question:  Function for Key board entries

Answer: I would like to know how can i create a function for the Key board entries like the F1, F2, F3....., ALT+TAB, Shift+Tab, etc. and can use it as a Business or Scripted Component in QC?


June 06, 2008 00:44:50 #1
 akothuru Testing Expert  Member Since: April 2008    Total Comments: 35 

RE: Function for Key board entries
 
Using SendKeys method, user can perform keyboard operations like Alf+F4 , Ctrl, Backspace etc in QTP... and it is a VB Script code

'Create Shell object to access Sendkeys method
Set objShell = CreateObject("WScript.Shell")
objShell.SendKeys "aaa" 'Enters the string "aaa" using keyboard
objShell.SendKeys "{F5}"  'Press F5 button Refresh
objShell.SendKeys "%{F4}"  'Close the currently activated window/browser

Note:
% represents Alt
+ represents Shift
^ represents Ctrl

  • e and c are pressed, send the string argument "+(ec)".
  • e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec".

  •      

     

    Back To Question