open and shut case

Erik Heneryd erik at heneryd.com
Sun Sep 12 13:11:53 CEST 2004


Elaine Jackson wrote:
> Can python close a web-browser window it opened itself? The window in question
> will be displaying a webpage that resides on the local computer, which is
> running Windows 98. Knowing a way to do this would really help me out.

Not easily.  I guess something like this could work, if you have Mark 
Hammonds win32 extensions installed:

(very untested)

import os, win32api
# start browser
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe", "iexplore.exe", 
r"c:\blabla\hej.html")
# ...
# kill browser
win32api.TerminateProcess(pid, 0)


HTH

Erik



More information about the Python-list mailing list