EnableExplicit Define PID Procedure KillProcess(pid) Protected phandle Protected result phandle = OpenProcess_(#PROCESS_TERMINATE, #False, pid) If phandle <> #Null If TerminateProcess_(phandle, 1) result = #True EndIf CloseHandle_(phandle) EndIf ProcedureReturn result EndProcedure RunProgram("notepad.exe") Delay(2000) GetWindowThreadProcessId_(FindWindow_("notepad",#Null),@PID) KillProcess(PID)