Closes a process that is the owner of a window with the specified handle.
Sub CloseProcessByHwnd_Example() 'The following example retrieves the handle of the Notepad window, ‘and then uses the CloseProcessByHwnd method to close the ‘notepad application. hWnd = Window("Notepad").GetROProperty("hwnd") SystemUtil.CloseProcessByHwnd (hWnd) End Sub
Closes a process according to its Process ID (PID).
Sub CloseProcessById_Example() 'The following example retrieves the process ID of the Notepad ‘window, and then uses the CloseProcessByID method to close the ‘notepad application. PID = Window("Notepad").GetROProperty("process id") SystemUtil.CloseProcessById (PID) End Sub
Closes a process according to its name.
Sub CloseProcessByName_Example() 'The following example uses the CloseProcessByName method to ‘close any open instances of Notepad. If the only instances of ‘Notepad that are open are those opened by the statements below, ‘then the MsgBox displays 3. SystemUtil.Run "Notepad.exe" SystemUtil.Run "Notepad.exe" SystemUtil.Run "Notepad.exe" MsgBox SystemUtil.CloseProcessByName("Notepad.exe") End Sub
Closes all processes that are owners of windows with the specified title.
Sub CloseProcessByWndTitle_Example1() 'The following example closes all top-level windows with a titlebar ‘that contains the string "Notepad", by specifying "Notepad" as a ‘regular expression. SystemUtil.CloseProcessByWndTitle "Notepad", True End Sub
If you want to keep track of further articles on UFT (QTP). I recommend you to subscribe by Email and have new UFT articles sent directly to your inbox.