How to detect open windows applications

Discussion in 'Python' started by Roy, Sep 16, 2004.

  1. Roy

    Roy Guest

    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.
    Roy, Sep 16, 2004
    #1
    1. Advertising

  2. Roy

    Tim Golden Guest

    Roy wrote:
    > 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.


    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="thunderbird.exe"):
    print p.ExecutablePath

    </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
    Tim Golden, Sep 16, 2004
    #2
    1. Advertising

  3. Hi !

    Search the process.

    @-salutations
    --
    Michel Claveau
    =?iso-8859-1?Q?Michel_Claveau_-_abstraction_m=E9ta, Sep 16, 2004
    #3
  4. Roy

    Roy Guest

    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. <> wrote in message news:<cicqq6$kra$>...
    > Hi !
    >
    > Search the process.
    >
    > @-salutations
    Roy, Sep 17, 2004
    #4
  5. Roy

    Guest

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


    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
    , Sep 17, 2004
    #5
  6. Roy

    Roy Guest

    Michel Claveau - abstraction méta-galactique non trivial e en fuite perpétuelle. <> wrote in message news:<cicqq6$kra$>...
    > Hi !
    >
    > Search the process.
    >
    > @-salutations


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

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

    app = 'WINWORD'
    try:
    index = processList.index(app)
    print "Application %s is running." % app
    except ValueError:
    print "Application %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!
    Roy, Sep 17, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Davis
    Replies:
    0
    Views:
    718
    John Davis
    Aug 21, 2003
  2. Wolfgang
    Replies:
    5
    Views:
    1,461
    Tris Orendorff
    Feb 19, 2004
  3. Replies:
    1
    Views:
    244
    Tommy Nordgren
    Dec 23, 2008
  4. Anil
    Replies:
    1
    Views:
    412
    Jean-Luc David [MS-MVP]
    Jul 31, 2004
  5. Trick Kid

    Detect open windows shares?

    Trick Kid, Apr 2, 2006, in forum: Perl Misc
    Replies:
    15
    Views:
    299
    robic0
    Apr 3, 2006
Loading...

Share This Page