reehdus wrote:
I tried that but I get stuck at EnumProcessModules. It tells me my access
is
denied. I'm not sure if I'm doing it right. My code is below:
import win32gui
import win32api
import win32con
from time import sleep
import win32process
sleep(2)
name = win32gui.GetForegroundWindow()
t,p = win32process.GetWindowThreadProcessId(name)
handle = win32api.OpenProcess(1,False,p)
sleep(1)
whee = win32process.EnumProcessModules(handle)
nama = win32process.GetModuleFileNameEx(whee, 0)
print nama
Thanks!
Roger Upole wrote:
A sequence like this should get you there.
win32gui.GetForegroundWindow
win32process.GetWindowThreadProcessId
win32api.OpenProcess
win32process.EnumProcessModules
win32process.GetModuleFileNameEx
hth
Roger
You'll need to use a different access mask for OpenProcess.
handle =
win32api.OpenProcess(win32con.PROCESS_VM_READ|win32con.PROCESS_QUERY_INFORMATION,False,p)
Also, GetModuleFileNameEx needs the process handle:
nama = win32process.GetModuleFileNameEx(handle, whee[0])
Roger
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32