is there a way to trigger an event (e.g. MQTT message) if a specific program is running on a Windows PC ?
Background:
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.
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 …
The other way mentioned - starting the program in question not directly but by a script - is no option in my case.
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.4.3.0.0\lib\net45\M2Mqtt.Net.dll" step
Finally I managed to get that stuff installed and got a script working.
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
I had a similiar situation - with the difference that I play VR games and want to get notified when somebody enters the room
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.