Micro Focus QTP (UFT) Forums
How to Verify if notepad is open - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to Verify if notepad is open (/Thread-How-to-Verify-if-notepad-is-open)



How to Verify if notepad is open - bostonma - 04-23-2010

Hi

I tried to write this code but it did not work.can someone please suggest me howto verify a notepad is open and if Yes then close?

'Close notepad if it is open
Code:
If Window("regexpwndtitle:=Notepad","regexpwndclass:=Notepad","is owned window:=False","is child window:=False").Exists Then
Window("regexpwndtitle:=Notepad","regexpwndclass:=Notepad","is owned window:=False","is child window:=False").Close
End If



RE: How to Verify if notepad is open - supputuri - 04-26-2010

SystemUtil.CloseProcessByName("notepad.exe")

This will close all the opened notepads.


RE: How to Verify if notepad is open - malleshjm - 04-29-2010

hi,

your code is correct.probably you might have kept opened multiple notepads.

Regards


RE: How to Verify if notepad is open - Seema Gupta - 04-13-2011

Above code is only to close one notepad. If their are more than one notepad to be closed then try with this code:


Code:
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = notepad
“)
For Each objProcess in colProcess
objProcess.Terminate()
Next
Regards,
Seema Gupta