If do this using DP code, we need to get the properties of error window and write one more line of code.
Dialog(“text:=Flight Reservations”).WinButton(“text:=OK”).Click
Instead of addind more objects in our code and writing extra lines for this, we can simply press escape key (ESC) from keyboard and our job is done!!
How can we do that using QTP?
All you need to do is, create a Wscript object and then you can use Sendkeys for that purpose.
Set oShell = CreateObject(“WScript.Shell”)
oShell.SendKeys “{ESC}”
Done!!
This thing is very useful when application have no automation interface. And it’s quite fast as well. Depends on the need.
Most keyboard characters are represented by a single keystroke. Some keyboard characters are made up of combinations of keystrokes (CTRL+SHIFT+HOME, for example).
– To send a single keyboard character, send the character itself as the string argument. For example,
– To send the letter x, send the string argument “x”.
– To send a space, send the string ” “.
– You cannot send the PRINT SCREEN key {PRTSC} to an application.
- oShell.SendKeys “{ESC}” – press escape key
- oShell.SendKeys “john” – type john
- oShell.SendKeys “+^{ESC}” – press Ctrl + Shift + Esc keys (open Windows Task Manager)
- oShell.SendKeys “%{F}” – press Alt + F key (open file menu)
For details of all the characters, please refer the following table.
i think CTRL & SHIFT characters need to be replaced in the table
no its right…
Its very nice explanation about using keyboard keys in detail.keep up the good work.
Thank you,
Krish
How do i do the sendkey for windows button?
Hi… I want a shortcut for print screen key on keyboard…While I am {PRTSC},its asking me for a printer than printing the screen..can anyone help me with this issue..
Thanks in advance
Hi, I am using below script to print the screen in paint, but not working. Can anyone assist me
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "+^{ESC}"
Systemutil.Run "D:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"
oShell.SendKeys "^{PRTSC}"
Systemutil.Run "D:WINDOWSSystem32mspaint.exe"
wait(5)
oShell.SendKeys "^Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "+^{ESC}"
Systemutil.Run "D:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"
oShell.SendKeys "^{PRTSC}"
Systemutil.Run "D:WINDOWSSystem32mspaint.exe"
wait(5)
oShell.SendKeys "^V"
Hi, what is the argumrnt for windows button