Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Need to check if a process is currently running

If you have a question or need help, this is the place to be.
Post Reply
dmehling
Posts: 29
Joined: Wed Jun 24, 2009 12:10 am

Need to check if a process is currently running

Post by dmehling »

I'm trying to create a macro which requires a process detecting action. For example, I need to know if Windows Media Center is currently open. Whether a process is running or not will determine if the macro can be executed. I thought process watcher might be what I need, but I can't figure out how to make it do anything.
Dragon470
Experienced User
Posts: 205
Joined: Thu Feb 10, 2011 2:16 am

Re: Need to check if a process is currently running

Post by Dragon470 »

You could use the process watcher plugin, but it would not tell you if the process was started before eventghost was started.

I made a script a log time ago specifically to see if windows media center currently running and/or recording. This requires you to use Windows Management Instrument (WMI). I have the wmi.py file attached. It needs to be put in the main eventghost install directory.

To see if WMC is running use:

Code: Select all

import wmi

c = wmi.WMI ()
for process in c.Win32_Process (name="ehShell.exe",sessionId="1"):
    print "WMC is recording"

To see if WMC is recording:

Code: Select all

import wmi

c = wmi.WMI ()
for process in c.Win32_Process (name="ehrec.exe",sessionId="0"):
    print "WMC is Running"
Attachments
wmi.py
(46.56 KiB) Downloaded 127 times
Post Reply