How to detect open windows applications

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

    #1

    How to detect open windows applications

    How do I know within my python script if a specific windows
    application is currently running in Windows 2000. Specifically, I
    would like to know of MSWORD is running. I have the win32 package
    installed. Thank you for your help.
  • Tim Golden

    #2
    Re: How to detect open windows applications

    Roy wrote:[color=blue]
    > How do I know within my python script if a specific windows
    > application is currently running in Windows 2000. Specifically, I
    > would like to know of MSWORD is running. I have the win32 package
    > installed. Thank you for your help.[/color]

    I'm sure there are other ways, but since no-one else has
    replied yet, you could use wmi:

    <code>
    import wmi

    c = wmi.WMI ()
    for p in c.Win32_Process (Name="thunderb ird.exe"):
    print p.ExecutablePat h

    </code>

    The example uses my wmi-wrapper module (Google for Python
    WMI) but you can do WMI with raw pywin32 -- all the module
    does is to make life a bit easier.

    TJG

    Comment

    • Michel Claveau - abstraction méta-galactique non t

      #3
      Re: How to detect open windows applications

      Hi !

      Search the process.

      @-salutations
      --
      Michel Claveau


      Comment

      • Roy

        #4
        Re: How to detect open windows applications

        That sounds like a good way...
        How do I get a list of the process?

        Michel Claveau - abstraction méta-galactique non trivial e en fuite perpétuelle. <unseulmcmcmcmc @msupprimerlepo int.claveauPOIN Tcom> wrote in message news:<cicqq6$kr a$1@news-reader4.wanadoo .fr>...[color=blue]
        > Hi !
        >
        > Search the process.
        >
        > @-salutations[/color]

        Comment

        • gh@ghaering.de

          #5
          Re: How to detect open windows applications

          On Fri, Sep 17, 2004 at 06:37:02AM -0700, Roy wrote:[color=blue]
          > That sounds like a good way...
          > How do I get a list of the process?[/color]

          That's possible with the win32 extensions. For a quick hack I often prefer to
          interface command-line utilities like the pulist.exe and kill.exe from the M$
          Resource Kit.

          -- Gerhard

          Comment

          • Roy

            #6
            Re: How to detect open windows applications

            Michel Claveau - abstraction méta-galactique non trivial e en fuite perpétuelle. <unseulmcmcmcmc @msupprimerlepo int.claveauPOIN Tcom> wrote in message news:<cicqq6$kr a$1@news-reader4.wanadoo .fr>...[color=blue]
            > Hi !
            >
            > Search the process.
            >
            > @-salutations[/color]

            I found it! (I think)
            Is the following code reasonable?
            ......
            import win32pdh

            processes = win32pdh.EnumOb jectItems(None, None, "Process", -1)
            processList = list(processes[1])

            app = 'WINWORD'
            try:
            index = processList.ind ex(app)
            print "Applicatio n %s is running." % app
            except ValueError:
            print "Applicatio n %s is not running." % app
            ......
            I don't care about index, which indicates where it is in the process list.

            Thank you for your help!

            Comment

            Working...