open and shut case

E

Elaine Jackson

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.

Peace
 
E

Erik Heneryd

Elaine said:
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
 
J

John J. Lee

Elaine Jackson said:
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.

There are quite a few examples of automating IE with COM lying around
on Google and Google Groups if you know what to look for.
Unfortunately, COM is be rather obscure in many ways.

terms: IE, MSIE, Internet Explorer, COM, pywin32, win32all, ctypes

The win32 mailing list (whose name I forget -- sorry!) is a good
source.

PS. these days, your subject line sounds distinctly spammish
(especially since it's a woman posting the message to a
comp. newsgroup -- how likely can that be? ;-)


John
 
E

Elaine Jackson

Thanks for the tips. The subject lines were meant to be humorous and hooky. I
guess I should know by now that it doesn't pay to attempt humor when there are
so many lower lifeforms around who can't imagine anything better to do than
peeing in the pool. C'est la vie, I guess. Anyway, thanks again.

Peace

|
| > 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.
|
| There are quite a few examples of automating IE with COM lying around
| on Google and Google Groups if you know what to look for.
| Unfortunately, COM is be rather obscure in many ways.
|
| terms: IE, MSIE, Internet Explorer, COM, pywin32, win32all, ctypes
|
| The win32 mailing list (whose name I forget -- sorry!) is a good
| source.
|
| PS. these days, your subject line sounds distinctly spammish
| (especially since it's a woman posting the message to a
| comp. newsgroup -- how likely can that be? ;-)
|
|
| John
 
A

Andrew Dalke

John said:
PS. these days, your subject line sounds distinctly spammish
(especially since it's a woman posting the message to a
comp. newsgroup -- how likely can that be? ;-)

What the .... ??! Was that supposed to be funny? The smiley
suggests you thought it was. It isn't. It's crude and rude.

Andrew
(e-mail address removed)
 
M

Mario Berger

PS. these days, your subject line sounds distinctly spammish
What the .... ??! Was that supposed to be funny? The smiley
suggests you thought it was. It isn't. It's crude and rude.

Andrew

Cut him some slack, he may be really battered by spam and kinda
sensitive on the issue ;)

~Mik

--
Top-Bottom Programming never gets you where you wanted to go.
Bottom-Top Programming gets you where you never wanted to go.

while not life:
sleep((sleep.normal_time - 5h)); eat(mode=fast); pc_mainloop()
 
C

Cliff Wells

What the .... ??! Was that supposed to be funny? The smiley
suggests you thought it was. It isn't. It's crude and rude.

I took the wink to mean that the statement was to be taken as facetious.
I didn't see it as particularly rude or otherwise.

Regards,
Cliff
 
J

John J. Lee

Andrew Dalke said:
What the .... ??! Was that supposed to be funny? The smiley
suggests you thought it was. It isn't. It's crude and rude.

Now *I'm* left thinking "What the.." . That went over my head... How
is it crude, or rude??

It just seemed funny that the very presence of a woman on this
newsgroup indicated spam to the sensitive spam-detection circuits my
brain has grown over the past few years.

If you want me to deconstruct the reasons why it seemed funny:

I suppose it fits the standard joke format, according to Vilayanur
Ramachandran (not sure the idea originates with him): a sudden
re-evaluation of the facts (it's not spam after all), and the
consequence turns out to be inconsequential (a perfectly valid
everyday post -- no harm has been done). The wink was mildly
self-mocking, I guess: The almost total absence of women from this
little virtual place must to some extent reflect badly on whatever
communities it comprises.

Maybe I should be pleased that I can't even imagine what it was you
thought I was saying...


John
 
C

Curt

Now *I'm* left thinking "What the.." . That went over my head... How
is it crude, or rude??

I didn't understand the ferocity of this reaction either nor could I imagine
what impure thoughts he was imputing to your rather innocent brain. It was
as if you had made some sort of snide, lasciviously abject remark for
which you should justifiably be banned from decent society for the rest of
your life. This inspired me to re-read what you had written in order to
savor the utter degradation of your comment which had either passed over
or under the sea level of my moral sensitivities.

But whatever it was or was imagined to be, if anything, is beyond
me.
 
C

Cameron Laird

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)
.
.
.
Did this meet your needs, Ms. Jackson? If not--if there's an issue
with win32api, or you're looking to use the default browser, insofar
as that differs from iexplore.exe, or ...--there are several other
approaches to this problem.
 
E

Elaine Jackson

| Did this [some snipped code] meet your needs, Ms. Jackson?

Here's what it does:
"iexplore.exe",r"c:\blabla\hej.html")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
"iexplore.exe",r"c:\blabla\hej.html")
AttributeError: 'module' object has no attribute 'spawnlp'
 
D

Dennis Lee Bieber

| Did this [some snipped code] meet your needs, Ms. Jackson?

Here's what it does:
"iexplore.exe",r"c:\blabla\hej.html")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
"iexplore.exe",r"c:\blabla\hej.html")
AttributeError: 'module' object has no attribute 'spawnlp'

It seems the spawn family doesn't have the "search in PATH"
option... os.execlp does exist, but likely doesn't do what you want
either...


--
 
E

Erik Heneryd

Dennis said:
| Did this [some snipped code] meet your needs, Ms. Jackson?

Here's what it does:

import os, win32api
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",

"iexplore.exe",r"c:\blabla\hej.html")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
"iexplore.exe",r"c:\blabla\hej.html")
AttributeError: 'module' object has no attribute 'spawnlp'


It seems the spawn family doesn't have the "search in PATH"
option... os.execlp does exist, but likely doesn't do what you want
either...

It does, see http://docs.python.org/lib/os-process.html.
exec* replaces the current process, so you can't use that if you expect
it to return. I can't see why my code shouldn't work (though I'm not on
a Windows box so I can't test it).


Erik
 
E

Erik Heneryd

Erik said:
Dennis said:
| Did this [some snipped code] meet your needs, Ms. Jackson?

Here's what it does:


import os, win32api
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",


"iexplore.exe",r"c:\blabla\hej.html")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
"iexplore.exe",r"c:\blabla\hej.html")
AttributeError: 'module' object has no attribute 'spawnlp'


It seems the spawn family doesn't have the "search in PATH"
option... os.execlp does exist, but likely doesn't do what you want
either...

It does, see http://docs.python.org/lib/os-process.html.
exec* replaces the current process, so you can't use that if you expect
it to return. I can't see why my code shouldn't work (though I'm not on
a Windows box so I can't test it).

Forget about it. I just actually read the spawn* docs:

Availability: Unix, Windows. spawnlp(), spawnlpe(), spawnvp() and
spawnvpe() are not available on Windows. New in version 1.6.


Erik
 
C

Cameron Laird

Erik said:
Dennis said:
On Sun, 26 Sep 2004 16:55:48 GMT, "Elaine Jackson"
<[email protected]> declaimed the following in
comp.lang.python:


| Did this [some snipped code] meet your needs, Ms. Jackson?

Here's what it does:


import os, win32api
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",


"iexplore.exe",r"c:\blabla\hej.html")

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
"iexplore.exe",r"c:\blabla\hej.html")
AttributeError: 'module' object has no attribute 'spawnlp'



It seems the spawn family doesn't have the "search in PATH"
option... os.execlp does exist, but likely doesn't do what you want
either...

It does, see http://docs.python.org/lib/os-process.html.
exec* replaces the current process, so you can't use that if you expect
it to return. I can't see why my code shouldn't work (though I'm not on
a Windows box so I can't test it).

Forget about it. I just actually read the spawn* docs:

Availability: Unix, Windows. spawnlp(), spawnlpe(), spawnvp() and
spawnvpe() are not available on Windows. New in version 1.6.
.
.
.
This is silly. Ms. Jackson has asked for an *extremely* basic
technique. I don't have a Win* keyboard within reach, and am
reluctant to speculate, at this point. I'm certain, though,
that her question has multiple simple answers. Ms. Jackson,
how urgent is your need? Does someone else want to chip in
with conclusive information?
 
E

Elaine Jackson

My need couldn't be less urgent. My cat just died and I can't even begin to get
interested in fiddling with the computer right now.

Peace


| In article <[email protected]>,
| >Erik Heneryd wrote:
| >> Dennis Lee Bieber wrote:
| >>
| >>> On Sun, 26 Sep 2004 16:55:48 GMT, "Elaine Jackson"
| >>> <[email protected]> declaimed the following in
| >>> comp.lang.python:
| >>>
| >>>
| >>>> | >>>> | Did this [some snipped code] meet your needs, Ms. Jackson?
| >>>>
| >>>> Here's what it does:
| >>>>
| >>>>
| >>>>>>> import os, win32api
| >>>>>>> pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
| >>>>
| >>>>
| >>>> "iexplore.exe",r"c:\blabla\hej.html")
| >>>>
| >>>> Traceback (most recent call last):
| >>>> File "<pyshell#1>", line 1, in -toplevel-
| >>>> pid = os.spawnlp(os.P_NOWAIT, "iexplore.exe",
| >>>> "iexplore.exe",r"c:\blabla\hej.html")
| >>>> AttributeError: 'module' object has no attribute 'spawnlp'
| >>>>
| >>>
| >>>
| >>> It seems the spawn family doesn't have the "search in PATH"
| >>> option... os.execlp does exist, but likely doesn't do what you want
| >>> either...
| >>>
| >>
| >> It does, see http://docs.python.org/lib/os-process.html.
| >> exec* replaces the current process, so you can't use that if you expect
| >> it to return. I can't see why my code shouldn't work (though I'm not on
| >> a Windows box so I can't test it).
| >
| >Forget about it. I just actually read the spawn* docs:
| >
| >Availability: Unix, Windows. spawnlp(), spawnlpe(), spawnvp() and
| >spawnvpe() are not available on Windows. New in version 1.6.
| .
| .
| .
| This is silly. Ms. Jackson has asked for an *extremely* basic
| technique. I don't have a Win* keyboard within reach, and am
| reluctant to speculate, at this point. I'm certain, though,
| that her question has multiple simple answers. Ms. Jackson,
| how urgent is your need? Does someone else want to chip in
| with conclusive information?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,208
Messages
2,571,082
Members
47,683
Latest member
AustinFairchild

Latest Threads

Top