At some point, I can't use Quit()
. So, I need to find the PID and kill the process using psutil
or os.kill
I already look at existing answers on StackOverflow but can't find them for PowerPoint. I already tried this, and it works on Excel but not PowerPoint. On PowerPoint Hwnd
does not return Hwnd ID as Excel does.
Code:
import win32process
import win32com.client
app = win32com.client.Dispatch('PowerPoint.Application')
t, p = win32process.GetWindowThreadProcessId(app.Hwnd) # app.Hwnd returns "<bound method Hwnd of <COMObject PowerPoint.Application>>"
print('PowerPoint PID : ' + str(p))