Hello Friends!
In this post we'll learn how to perform keyboard operation in QTP using vbscript.
What's the need of Sendkeys?
Hmmm... ok.. Refer the blow code.
Set oShell = CreateObject("WScript.Shell")
SystemUtil.Run "D:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Click
oShell.SendKeys "john"
Dialog("text:=Login").WinEdit("attached text:=Password:").Click
oShell.SendKeys "wrong "
Dialog("text:=Login").WinButton("text:=OK").Click
Copy this code in QTP and run it.
Okie.. Now you can see, because we have entered incorrect password, following error dialog will be displayed.
Now we need to close error dialog and enter correct password in the login window.
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.
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).
Please note:-
- 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.
Examples:
- 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.
In case of any queries, please post your comments.
i think CTRL & SHIFT characters need to be replaced in the table
ReplyDeleteMachine Learning Projects for Final Year machine learning projects for final year
DeleteDeep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Deep Learning Projects for Final Year even arrange a more significant compensation.
Python Training in Chennai Project Centers in Chennai
no its right...
ReplyDeleteIts very nice explanation about using keyboard keys in detail.keep up the good work.
ReplyDeleteThank you,
Krish
How do i do the sendkey for windows button?
ReplyDeleteYou can try Ctrl+Esc combination for it...
Deletei.e. ^{ESC}
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..
ReplyDeleteThanks in advance
Hi, I am using below script to print the screen in paint, but not working. Can anyone assist me
ReplyDeleteSet oShell = CreateObject("WScript.Shell")
oShell.SendKeys "+^{ESC}"
Systemutil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
oShell.SendKeys "^{PRTSC}"
Systemutil.Run "D:\WINDOWS\System32\mspaint.exe"
wait(5)
oShell.SendKeys "^Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "+^{ESC}"
Systemutil.Run "D:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe"
oShell.SendKeys "^{PRTSC}"
Systemutil.Run "D:\WINDOWS\System32\mspaint.exe"
wait(5)
oShell.SendKeys "^V"
Hi, what is the argumrnt for windows button
ReplyDeleteHow can send Alt+ space
ReplyDeleteHow can i SEND CTRL+C??
ReplyDeletehow to open IE in private mode through qtp
ReplyDeleteHow I can send CTRL + T in mainframe by QTP
ReplyDeleteHi,
ReplyDeletei need some more information on Send keys for TAB and ENTER where haing multiple webelements in webtable which are having same propertis
Hi,
ReplyDeleteI am using send keys for right click button and then select context menu. but I am unable to run. I want to perform below operation:
Right click -> Open -> buy.
I am using send keys {DOWN} and {ENTER}
Script has been running but next page is not opening.
How do I send a string in WinEdit box using sendkeys??
ReplyDeletehaii,
ReplyDeleteI need sendkey shortcut for windows key
try this alt+space+c
ReplyDeleteWhat is the shortcut for windows key or F10
DeleteUnable to type F10 key for automation by VB script. Please let me know
DeleteAnyone please guide me
Deleteđồng tâm
ReplyDeletegame mu
cho thuê nhà trọ
cho thuê phòng trọ
nhac san cuc manh
số điện thoại tư vấn pháp luật miễn phí
văn phòng luật
tổng đài tư vấn pháp luật
dịch vụ thành lập công ty trọn gói
lý thuyết trò chơi trong kinh tế học
đức phật và nàng audio
hồ sơ mật dinh độc lập audio
đừng hoang tưởng về biển lớn ebook
chiến thắng trò chơi cuộc sống ebook
bước nhảy lượng tử
ngồi khóc trên cây audio
truy tìm ký ức audio
mặt dày tâm đen audio
thế giới như tôi thấy ebook
nhã hứng của hai vị…” Trình Phi nói chuyện với Lưu Phong so với Chu Cao Phi thì quả nhiên là lễ độ hơn nhiều.
Chờ đến khi hắn ngẩng đầu lên thì ba người Lưu Phong đã đi được một đoạn.
Cẩn thận ngẫm nghĩ lại câu nói lúc nãy của Lưu Phong, Trình Phi có chút mệt mỏi, thì thầm tự nói với chính mình: “Làm người thì ai mà chả muốn làm người, có ai muốn làm chó đâu nhưng ta thực sự không có cơ hội làm người…”
Trình Phi nói câu này Lưu Phong không nghe được, nếu không dám chắc hắn sẽ vỗ vai Trình Phi mà nói: “Cơ hội chính là do mình tranh thủ mà có.” Mặc dù Lưu Phong cũng không biết có đúng là như vậy hay không nhưng muốn khích lệ người khác, ắt phải nói như vậy.
Cắt đuôi được Trình Phi, Lưu Phong nắm tay Vương Đông Đông và tiểu Linh nhi đi. Trong lòng thầm tính toán, đợi khi nàng hoàn toàn phát dục thì mông nàng chắc sẽ lớn hơn mông của Liễu Thanh Nghi. Mông phải có hình dạng số 3 mới đúng là hoàn mỹ.
Ngay khi dâm ý trong lòng hắn đang dâng trào thì một thanh âm quen thuộc vang lên: “Lưu đại thiếu gia, thật là xảo hợp. Lại gặp ngươi ở chỗ này.” Sau đó một đám người do Tam đầu heo dẫn đầu xuất hiện giữa đường.
Lưu Phong khinh thường nhìn Tam đầu heo, nghĩ thầm, tên này quả thực là ngu xuẩn chí cực. Chưa nói đã thấy ngu.
“Đúng vậy, thật là xảo hợp.” Lưu Phong cười cười, tiếp tục đi như trước, hai tay dắt hai vị mỹ nữ, đi đến trước mặt Chu Tam rồi dừng lại. Nhìn thoáng qua đám người sau lưng hắn, cười nói: “Trư Tam công tử, đi bộ mà sao mang theo nhiều cẩu vậy?”
What do you want to say?
Deletewhat is the argument for windows logo key.
ReplyDeleteor how to launch "Run" using vbscript.
hi i want to use ctrl And numpad0 together what should i used. I want to make zoom level to default
ReplyDeletevery nice information.
ReplyDelete"best andaman honeymoon packages
andaman honeymoon tour packages "
Please refer below if you are looking for best Training center in coimbatore
DeleteJava Training in Coimbatore | Digital Marketing Training in Coimbatore | SEO Training in Coimbatore | Tally Training in Coimbatore | Python Training In Coimbatore | PMP Training In Coimbatore | Scrum Training In Coimbatore
Thank you for excellent article.
Excellent post. I was always checking this blog, and I’m impressed! Extremely useful info specially the last part, I care for such information a lot. I was exploring this particular info for a long time. Thanks to this blog my exploration has ended. Extratorrent
ReplyDeleteIt was a decent post to be sure. I completely delighted in understanding it in my lunch time. Will definitely come and visit this blog all the more frequently. Much obliged for sharing. Gear Hint
ReplyDeleteThe Logitech contains a few fascinating and inventive highlights which can assist you with performing at your best in games, for example, amazing.gaming Keyboard reviews
ReplyDeletenice post. thanks for sharing this.
ReplyDeleteroller blinds
Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. best budget gaming keyboard
ReplyDeleteFinally, no matter how simple the programming of the keyboard is the program needs to be downloaded into the keyboard. A simple to use program needs to be included with the keyboard for downloading. It also needs to check for coding errors. best keyboard for programmers
ReplyDeleteIncredible occupation for distributing such a valuable site. Your web log isn't just helpful yet it is also extremely inventive as well. There will in general be relatively few individuals who can absolutely compose not all that straightforward posts that masterfully. Proceed with the pleasant composition blackhatforum
ReplyDelete