[python-win32] Trying to grab exe of foreground window
reehdus
sudheer_87 at hotmail.com
Wed Jul 22 04:34:11 CEST 2009
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
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
>
--
View this message in context: http://www.nabble.com/Trying-to-grab-exe-of-foreground-window-tp24582049p24599109.html
Sent from the Python - python-win32 mailing list archive at Nabble.com.
More information about the python-win32
mailing list