| || |
How to close Multiple windows based on .net or vb forms in one go
Can someone let me know how can i close multiple form windows at one go. Actually I am able to see multiple instances of the application with different names in taskmanager. So unable to close using task manager. All the window names are dynamic in nature. And I cannot close the main window until all other windows are closed.
Will appreciate any code snippet.
Just to add on I am looking for any property like creation time for browser, if we have any similar for the window form.
you can try hwnd property for windows. The values would be dynamic for that you can use regexp
Venu, How can I use this as suppose there are 3 windows then, then again problem will occur which window to close. SO QTP/UFT throws error found multiple instances. I have used follwoing code currently:-
Public Sub CloseAllWindows
i = 5
For j = 1 To 5
If swfwindow("swfname:=.*","StartPosition:="&i).exist (0) Then
i = i - 1
But I am looking for some other permanent solution as again there as again if position is same then again conflicts occur.
If someone can let me know permanent solution will be appreciable . thanks.
Try the below for SWFWindow and check.
I tried for multiple dialogs with the below code and as mentioned above by @venu get hwnd or any property value neccesary or directly use the close method to close the windows. Let know if it worked.
Set oWindow = Description.Create()
oWindow("micClass").Value = "Dialog"
Set oChildObjects = Desktop.ChildObjects(oWindow)
MsgBox oChildObjects(0).GetROProperty("hwnd") .. .. etc.,
Thanks Prashin. Will try your solution.
Did you tried closing the child objects. Code will be something like
for each oWindow in objChildObjects
You can use
CloseDescendentProcessess to close all the windows at a time
Set app = CreateObject("WScript.shell")