09-02-2009, 11:24 AM
(08-24-2009, 07:44 PM)basanth27 Wrote: [/code]Set fso = CreateObject("WScript.Shell")
While fso.AppActivate("Your Window Name") = FALSE
wscript.sleep 1000
Wend
fso.SendKeys "a", True
fso.SendKeys "N", True
wscript.sleep 7000
While fso.AppActivate ("Your Window Name") = FALSE
wscript.sleep 1000
Wend
fso.SendKeys "N", True
[code]
Ugh...I wrote a lot and everything seems to have got deleted other than the Code :-).
Okay i am going to rewrite the whole stuff.
There are several instances when QTP hangs due to a window appearing on the screen. Reasons debated being several, the core issue is derieved from the very fact about the outlook security window which appears and freezes the qtp script. To negate this situation a execution of a external vbs file which parallelly works to counter the windows presence and hence closing it through the keystrokes helps qtp to proceed further.
1. Save the above code as dialoghandler.vbs on your c:\ drive.
2. Be sure to modify the code to replace the window title or name.
3. Replace the appropriate keystrokes you need to send for the dialog. [ for eg :you may need to press "Enter" which inturn actually clicks on "OK" or "cancel" button.
4. Just before the line on QTP where the code executes and freezes QTP, enter this code,
SystemUtil.Run "C:\Windows\System32\Wscript.exe", "C:\dialoghandler.vbs"
This Solution was provided to me by Yaron Assa of the AdvancedQtp Fame.
Let me know if you have any questions.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.