Acquiring process handle and convert it into PID

Michael C <[email protected]> Tue, 29 Nov 2016 14:07:26 -0800
Newsgroups gmane.comp.python.ctypes
Message-ID <CANyKM1iRzUSACvwJnuS0gESi0Sdhpmk4TSevBOBpQoXDwG7uwA@mail.gmail.com>
I ran this but the value returned was 0. I am trying to save time by
automating the PID acquisition process.
thx all


import ctypes
import time

time.sleep(2)
handle = ctypes.windll.user32.GetForegroundWindow()
print(handle)
PID = ctypes.windll.kernel32.GetProcessId(handle)
print (PID)

------------------------------------------------------------------------------

_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users