It is currently February 25th, 2021, 10:59 pm

[Help] Run rainmeter skin when a specific app is open

Help with creating, editing & fixing problems with skins
kruzade
Posts: 3
Joined: January 14th, 2021, 1:21 pm

[Help] Run rainmeter skin when a specific app is open

Post by kruzade »

How do you setup a skin to only run when a specific application is active? The goal is to have my customized SpotifyControl to only be active when a game is open. The SpotifyControl will be "Stay at top most" in order to show up as part of my UI when I stream. But it's fairly annoying to be hovering in my screen when I dont have the game up and I'm only browsing on web. My current solution is to have a toggle key for this, but I'm looking for a better solution; hence the topic.
User avatar
jsmorley
Developer
Posts: 21546
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Help] Run rainmeter skin when a specific app is open

Post by jsmorley »

You will need to use something like this:

First, create this skin, and be sure it is running all the time. It won't display anything. It's entire purpose is to keep track of whether or not the process you are interested in is currently running. It will also keep track of whether or not the skin you want to activate when the process IS running is currently active or not.

Code: Select all

[Rainmeter]
Update=1000

[Variables]

[MeasureConfig]
Measure=Plugin
Plugin=ConfigActive
ConfigName=ActionSlideClock

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=Notepad.exe
IfCondition=(MeasureProcess=1) && (MeasureConfig=-1)
IfTrueAction=[!ActivateConfig "ActionSlideClock" "ActionSlideClock.ini"]
IfCondition2=(MeasureProcess=-1) && (MeasureConfig=1)
IfTrueAction2=[!DeactivateConfig "ActionSlideClock"]

[MeterDummy]
Meter=String
So if the process is detected to be running, and the config is not active, it will load the config. If the process is detected to be not running and the config is active, it will deactivate the config.

ConfigActive plugin
This is a little plugin I wrote that will allow you to detect if a particular config (skin) is active. I recommend this for one reason, to keep Rainmeter from spitting out an error in the log if you try to active a config that is already running, or try to deactivate a config that isn't running. Those errors don't really cause any harm, but they are a bit annoying and I can do without them.

Then you use these features built into Rainmeter:

https://docs.rainmeter.net/manual/plugins/process/
https://docs.rainmeter.net/manual/bangs/#ActivateConfig
https://docs.rainmeter.net/manual/bangs/#DeactivateConfig

Obviously the process and config I used are not what you are looking for, but I don't use Spotify nor do I have the skin you are using. Just use what I did as an example and change it to reflect what you need.
kruzade
Posts: 3
Joined: January 14th, 2021, 1:21 pm

Re: [Help] Run rainmeter skin when a specific app is open

Post by kruzade »

Thanks, actually found that this worked at well.

Code: Select all

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=overwatch.exe
Substitute="-1":"not running","1":"running"
IfAboveValue=0
IfAboveAction=[!ShowFade]
IfBelowValue=0
IfBelowAction=[!HideFade]
User avatar
jsmorley
Developer
Posts: 21546
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Help] Run rainmeter skin when a specific app is open

Post by jsmorley »

kruzade wrote: January 14th, 2021, 2:02 pm Thanks, actually found that this worked at well.

Code: Select all

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=overwatch.exe
Substitute="-1":"not running","1":"running"
IfAboveValue=0
IfAboveAction=[!ShowFade]
IfBelowValue=0
IfBelowAction=[!HideFade]
Sure, if the point is to just "hide" the skin, that works perfectly well!
kruzade
Posts: 3
Joined: January 14th, 2021, 1:21 pm

Re: [Help] Run rainmeter skin when a specific app is open

Post by kruzade »

Is it possible for rainmeter to recognize what window is active (alt+tab'd)?
User avatar
jsmorley
Developer
Posts: 21546
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Help] Run rainmeter skin when a specific app is open

Post by jsmorley »

kruzade wrote: January 14th, 2021, 2:41 pm Is it possible for rainmeter to recognize what window is active (alt+tab'd)?
https://forum.rainmeter.net/viewtopic.php?f=128&t=33146&p=164704&#p164704

Keep in mind that this will identify the "title" of the active window, the window that currently has "focus". This is not a way, nor is there a good way I am aware of, to determine for sure what "process" owns that window.

Quite often a window title will contain the name of the application in it, but it might be at the beginning or the end of a longer string that identifies what document is open in the application or other information.

You can probably use IfMatch https://docs.rainmeter.net/manual/measures/general-options/ifmatchactions/ to zero in on the name of the application and take some action based on it.