open and shut case

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elaine Jackson

    #1

    open and shut case

    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


  • Erik Heneryd

    #2
    Re: open and shut case

    Elaine Jackson wrote:[color=blue]
    > 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.[/color]

    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.e xe", "iexplore.e xe",
    r"c:\blabla\hej .html")
    # ...
    # kill browser
    win32api.Termin ateProcess(pid, 0)


    HTH

    Erik

    Comment

    • John J. Lee

      #3
      Re: open and shut case

      "Elaine Jackson" <elainejackson7 355@home.com> writes:
      [color=blue]
      > 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.[/color]

      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

      Comment

      • Elaine Jackson

        #4
        Re: open and shut case

        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

        "John J. Lee" <jjl@pobox.co m> wrote in message news:878ybfk3rf .fsf@pobox.com. ..
        | "Elaine Jackson" <elainejackson7 355@home.com> writes:
        |
        | > 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


        Comment

        • Andrew Dalke

          #5
          Re: open and shut case

          John J. Lee wrote:[color=blue]
          > 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? ;-)[/color]

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

          Andrew
          dalke@dalkescie ntific.com

          Comment

          • Mario Berger

            #6
            Re: open and shut case

            >> PS. these days, your subject line sounds distinctly spammish[color=blue][color=green]
            >> (especially since it's a woman posting the message to a
            >> comp. newsgroup -- how likely can that be? ;-)[/color]
            >
            >
            > What the .... ??! Was that supposed to be funny? The smiley
            > suggests you thought it was. It isn't. It's crude and rude.
            >
            > Andrew[/color]

            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.no rmal_time - 5h)); eat(mode=fast); pc_mainloop()

            Comment

            • Cliff Wells

              #7
              Re: open and shut case

              On Sun, 2004-09-12 at 17:54 +0000, Andrew Dalke wrote:[color=blue]
              > John J. Lee wrote:[color=green]
              > > 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? ;-)[/color]
              >
              > What the .... ??! Was that supposed to be funny? The smiley
              > suggests you thought it was. It isn't. It's crude and rude.[/color]

              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

              --
              Cliff Wells <clifford.wells @comcast.net>

              Comment

              • John J. Lee

                #8
                Re: open and shut case

                Andrew Dalke <adalke@mindspr ing.com> writes:
                [color=blue]
                > John J. Lee wrote:[color=green]
                > > 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? ;-)[/color]
                >
                > What the .... ??! Was that supposed to be funny? The smiley
                > suggests you thought it was. It isn't. It's crude and rude.[/color]

                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

                Comment

                • Curt

                  #9
                  Re: open and shut case

                  On 2004-09-12, John J. Lee <jjl@pobox.co m> wrote:
                  [color=blue][color=green]
                  >> What the .... ??! Was that supposed to be funny? The smiley
                  >> suggests you thought it was. It isn't. It's crude and rude.[/color][/color]
                  [color=blue]
                  > Now *I'm* left thinking "What the.." . That went over my head... How
                  > is it crude, or rude??[/color]

                  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.

                  Comment

                  • Cliff Wells

                    #10
                    Re: open and shut case

                    On Mon, 2004-09-13 at 14:30 +0000, Curt wrote:[color=blue]
                    > This inspired me to re-read what you had written in order to
                    > savor the utter degradation of your comment[/color]

                    LMAO!

                    --
                    Cliff Wells <clifford.wells @comcast.net>

                    Comment

                    • Cameron Laird

                      #11
                      Re: open and shut case

                      In article <mailman.3201.1 094987518.5135. python-list@python.org >,
                      Erik Heneryd <erik@heneryd.c om> wrote:[color=blue]
                      >Elaine Jackson wrote:[color=green]
                      >> 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.[/color]
                      >
                      >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.e xe", "iexplore.e xe",
                      >r"c:\blabla\he j.html")
                      ># ...
                      ># kill browser
                      >win32api.Termi nateProcess(pid , 0)[/color]

                      Comment

                      • Elaine Jackson

                        #12
                        Re: open and shut case


                        "Cameron Laird" <claird@lairds. us> wrote in message
                        news:nf1i22-7hd.ln1@lairds. us...
                        | Did this [some snipped code] meet your needs, Ms. Jackson?

                        Here's what it does:
                        [color=blue][color=green][color=darkred]
                        >>> import os, win32api
                        >>> pid = os.spawnlp(os.P _NOWAIT, "iexplore.e xe",[/color][/color][/color]
                        "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.e xe",
                        "iexplore.exe", r"c:\blabla\hej .html")
                        AttributeError: 'module' object has no attribute 'spawnlp'


                        Comment

                        • Dennis Lee Bieber

                          #13
                          Re: open and shut case

                          On Sun, 26 Sep 2004 16:55:48 GMT, "Elaine Jackson"
                          <elainejackson7 355@home.com> declaimed the following in
                          comp.lang.pytho n:
                          [color=blue]
                          >
                          > "Cameron Laird" <claird@lairds. us> wrote in message
                          > news:nf1i22-7hd.ln1@lairds. us...
                          > | Did this [some snipped code] meet your needs, Ms. Jackson?
                          >
                          > Here's what it does:
                          >[color=green][color=darkred]
                          > >>> import os, win32api
                          > >>> pid = os.spawnlp(os.P _NOWAIT, "iexplore.e xe",[/color][/color]
                          > "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.e xe",
                          > "iexplore.exe", r"c:\blabla\hej .html")
                          > AttributeError: 'module' object has no attribute 'spawnlp'
                          >[/color]

                          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...


                          --[color=blue]
                          > =============== =============== =============== =============== == <
                          > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
                          > wulfraed@dm.net | Bestiaria Support Staff <
                          > =============== =============== =============== =============== == <
                          > Home Page: <http://www.dm.net/~wulfraed/> <
                          > Overflow Page: <http://wlfraed.home.ne tcom.com/> <[/color]

                          Comment

                          • Erik Heneryd

                            #14
                            Re: open and shut case

                            Dennis Lee Bieber wrote:[color=blue]
                            > On Sun, 26 Sep 2004 16:55:48 GMT, "Elaine Jackson"
                            > <elainejackson7 355@home.com> declaimed the following in
                            > comp.lang.pytho n:
                            >
                            >[color=green]
                            >>"Cameron Laird" <claird@lairds. us> wrote in message
                            >>news:nf1i22-7hd.ln1@lairds. us...
                            >>| Did this [some snipped code] meet your needs, Ms. Jackson?
                            >>
                            >>Here's what it does:
                            >>
                            >>[color=darkred]
                            >>>>>import os, win32api
                            >>>>>pid = os.spawnlp(os.P _NOWAIT, "iexplore.e xe",[/color]
                            >>
                            >>"iexplore.exe ",r"c:\blabla\h ej.html")
                            >>
                            >>Traceback (most recent call last):
                            >> File "<pyshell#1 >", line 1, in -toplevel-
                            >> pid = os.spawnlp(os.P _NOWAIT, "iexplore.e xe",
                            >>"iexplore.exe ",r"c:\blabla\h ej.html")
                            >>AttributeErro r: 'module' object has no attribute 'spawnlp'
                            >>[/color]
                            >
                            >
                            > 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...
                            >[/color]

                            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

                            Comment

                            • Erik Heneryd

                              #15
                              Re: open and shut case

                              Erik Heneryd wrote:[color=blue]
                              > Dennis Lee Bieber wrote:
                              >[color=green]
                              >> On Sun, 26 Sep 2004 16:55:48 GMT, "Elaine Jackson"
                              >> <elainejackson7 355@home.com> declaimed the following in
                              >> comp.lang.pytho n:
                              >>
                              >>[color=darkred]
                              >>> "Cameron Laird" <claird@lairds. us> wrote in message
                              >>> news:nf1i22-7hd.ln1@lairds. us...
                              >>> | 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.e xe",
                              >>>
                              >>>
                              >>> "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.e xe",
                              >>> "iexplore.exe", r"c:\blabla\hej .html")
                              >>> AttributeError: 'module' object has no attribute 'spawnlp'
                              >>>[/color]
                              >>
                              >>
                              >> 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...
                              >>[/color]
                              >
                              > 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).[/color]

                              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

                              Comment

                              Working...