How to trigger event if specific Windows program is running


is there a way to trigger an event (e.g. MQTT message) if a specific program is running on a Windows PC ?

When I do some Simracing I wont hear anything if someone of the family calls (due to headphones) me and any disturbance may ruin my race.
So I want a light to go red automatically if my simulation program is running. I’ve looked around Github a little but did not find a suitable solution. My best guess would be a little daemon which fires an MQTT message if a specific Windows program starts running and a second message if the program stops.

Any Ideas ?

Have you looked at mqttwarn?

Yes. With mqttwarn I could start a Win program but not react on the start of a Win program. :frowning:

I don’t do windows but there are two options there you can maybe explore
Let us know of your progress

I tried Bill2 Process Manager and at first glance it was looking good. But unfortunately it does not allow to create rules for processes started with high priority … :disappointed_relieved:

The other way mentioned - starting the program in question not directly but by a script - is no option in my case.

just a rough draft

  • use a power-shell script to check if process is running
  • run the script every minute using schedule task
  • set an expire to the item of two minutes

howto mqtt with power-shell :

if (Get-Process <processname>)
  <send mqtt message>

Tried that but didn’t manage to get the mqtt library istalled :face_with_symbols_over_mouth:

indeed the installation isn’t working as descripted at the page, it’s a long time since i set it up myself
but here is a solution to that

  • go to
  • download nuget.exe - recommended latest v4.6.2
  • start a power-shell with administration rights
  • navigate to the place you downloaded nuget.exe to
  • run nuget.exe install M2MQTT

this will install M2MQTT to the place where nuget.exe is located, you can than procced following the guide at the Add-Type -Path "<path>M2Mqtt.\lib\net45\M2Mqtt.Net.dll" step

1 Like

@mueslee: You’re hero !

Finally I managed to get that stuff installed and got a script working. :rofl:

The (standard) Win10 task scheduler options allows repeating a task only every 5 minutes - you have to manually edit to get a one minute repetition.
The program/script field in task scheduler action tab must point to the powershell executable itself. The “add arguments” field has to be set to
-WindowStyle Hidden -noninteractive -command "&{<path to your ps1 script>}"

If you want to prevent the blink of the blue powershell window (which is deadly during games) set the task to Run whether user is logged on or not on the general tab under “Security Options” section

nice to hear that it’s working :slight_smile: could you please mark the thread as solved?

I had a similiar situation - with the difference that I play VR games and want to get notified when somebody enters the room :smiley:
My approach was to setup a door sensor (obviously requires the door to be shut) and have a “Game Mode” switch in OH. If it is turned on and the sensor notices the door being opened, I get a Telegram push message on my Smartwatch.

I like to sim race as well!!