It is currently March 29th, 2024, 7:19 am

Help change skin with application

Get help with creating, editing & fixing problems with skins
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Help change skin with application

Post by maxwell1 »

Hi !
I wanted to know if there was a way to change a skin when a certain application/software is launched.
I have a gif as a skin on my desktop and I would like it to change when I launch a game, and whenever I stop the game, the skin goes back to the desktop one.
I know you can have multiple gifs for a same skin (the only exemple I have is "annoying dog" by DanielXiong which you can change by right clicking it and stuff if that can illustrate more what I mean).

Thank you very much :D
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Help change skin with application

Post by eclectic-tech »

The Process plugin will measure the state of any process; you can then use IfCondition checks to control actions.
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Re: Help change skin with application

Post by maxwell1 »

Okay I'm going to try this thank you :D
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Re: Help change skin with application

Post by maxwell1 »

Soooo I tried something based on what I understood from waht you recommanded me but since I don't know anything about rainmeter coding I have no idea why it isn't working.
Here's what I tried based on DanielXiong's "annoying dog". I modified it depending on what I wanted and haven't forget to change the Variables.ini to fit the changes I made.
Also if you could explain to me how to tell the program what software/game I want to launch. I tried with PUBG (which is named TslGame.exe for some reason but when I launched the game nothing happened (the gif didn't change). (And yeah I haven't changed the author name yet)

Thank you very much


Code: Select all

[Rainmeter]

Update=100


RightMouseUpAction=[!WriteKeyValue Variables Action1 #Action2#][!WriteKeyValue Variables Action2 #Action3#][!WriteKeyValue Variables Action3 #Action4#][!WriteKeyValue Variables Action4 #Action1#][!Refresh]

[Variables]
@Include=#@#\Variables.inc
Orientation1=Left
Orientation2=Right
Action1=Sleep
Action2=Stand
Action3=Play
Action4=Pubg

[Metadata]
Author=DanielXiong
Version=1.4.3
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=A little bear. |RMB=Change Normal Dog/Endogeny
Preview=Preview.png

[MeasureBackgroundFrameCalc]
Measure=Calc
Formula=Counter % 8
Substitute=".00000":""
Disabled=0
DynamicVariables=1

[MeterBackgroundFrame]
Meter=Image
X=0
Y=0
ImageName="#SKINSPATH#BK\@Resources\Images\Annoying Dog\#Action1#.\#Action1#[measureBackgroundFrameCalc].png"
DynamicVariables=1

[MeasureProcess]

Measure=Plugin
Plugin=Process
ProcessName=TslGame.exe
Substitute="0":"not running","1":"running"



[Process state]

IfCondition=1
IfTrueAction=[!WriteKeyValue Variables Action2 #Action4#]
IfCondition=0
IfFalseAction=[!WriteKeyValue Variables Action4 #Action2#]
Last edited by balala on April 25th, 2019, 7:01 pm, edited 1 time in total.
Reason: Please use <code> tags whever you're posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help change skin with application

Post by balala »

maxwell1 wrote: April 25th, 2019, 6:51 pm Here's what I tried based on DanielXiong's "annoying dog". I modified it depending on what I wanted and haven't forget to change the Variables.ini to fit the changes I made.
I hope eclectic-tech you don't mind if I intervine, but there are more issues I see:
  • So, maxwell1, first note that I can't try out your code, because there would be needed a few files, which I don't have. First the Variables.inc, which stores the needed variable and secondly the images used into the [MeterBackgroundFrame] meter.
  • The [Process state] measure (this should have to be a measure, but not having the Measure=... option, it isn't in fact and as such you can't use IfConditions onto it), is anyway wrong, because it has nothing except two IfCondition (as I said above). And even if you'd set the section as a measure (adding a Measure=Calc option for example), the IfConditions still wouldn't work properly, because there are two IfConditions (you can never duplicate any option into any section of a code, as same as you can't duplicate the names of sections - in such cases the second occurrence of the duplicated section or option is simply ignored). Anyway IfCondition=1 is always true (1 means true), while IfCondition=0 is always false (0 means false). The reason of the IfConditions is to use a condition which can be true or false and execute some bangs accordingly. For example the IfCondition=(#CURRENTSECTION#>0) checks if the value of the current section (where you've used the condition) is greater then 0 and if it is, the bangs posted into the IfTrueAction option are executed, otherwise, if it isn't true, the bangs of IfFalseAction are executed. As you've wrote those options, IfCondition=0 is ignored (explained above), IfCondition=1 is true and as such, the bang of IfTrueAction is executed (so the value of Action4 is written as the Action2 variable). But again, all these will work only if you tell Rainmeter that [Process state] is a measure, setting its type (as said above adding a Measure=... option).
  • Beside this, note that although it's not forbidden, nor a good idea isn't to use spaces into the names of section. Instead of [Process state] name I'd recommend [Processstate]. Will avoid a lot of headaches: https://forum.rainmeter.net/viewtopic.php?f=5&t=31683&p=160586&hilit=spaces+section+name#p160586
  • Keep in mind that a Process plugin measure returns 1 if the process is running and -1 (not 0) if it's not. So finally the Substitute option of the [MeasureProcess] measure is wrong because not the 0 value should have to be replaced when the process isn't running, but -1. Replace the following option: Substitute="0":"not running","1":"running" with Substitute="-1":"not running","1":"running"
  • To change the skin accordingly to the status of the process, add IfCondition to the [MeasureProcess] measure. For example:

    Code: Select all

    [MeasureProcess]
    ...
    IfCondition=(#CURRENTSECTION#>0)
    IfTrueAction= - ADD HERE THE BANGS YOU WANT TO EXECUTE WHEN THE PROCESS IS RUNNING -
    IfFalseAction= - ADD HERE THE BANGS YOU WANT TO EXECUTE WHEN THE PROCESS ISN'T RUNNING -
    If you want to execute IfTrueAction / IfFalseAction options posted into the [Process state] section (which I suppose you want), add them to the [MeasureProcess] measure:

    Code: Select all

    [MeasureProcess]
    Measure=Plugin
    Plugin=Process
    ProcessName=TslGame.exe
    Substitute="0":"not running","1":"running"
    IfCondition=(#CURRENTSECTION#>0)
    IfTrueAction=[!WriteKeyValue Variables Action2 "#Action4#"]
    IfFalseAction=[!WriteKeyValue Variables Action4 "#Action2#"]
    Here note that I included the values you have to write into quotes. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137628&hilit=quote+enclose+option#p137628
maxwell1 wrote: April 25th, 2019, 6:51 pm Also if you could explain to me how to tell the program what software/game I want to launch. I tried with PUBG (which is named TslGame.exe for some reason but when I launched the game nothing happened (the gif didn't change). (And yeah I haven't changed the author name yet)
You have to use the full path and name of the file which has to be executed when you want to launch the game. For example adding the LeftMouseUpAction=["c:\Windows\notepad.exe"] option to a meter, you can launch Notepad clicking that meter. Obviously you have to replace the above path with the correct one, but this is the idea: add the appropriate path into the appropriate option. I'm not sure when and how would you like to launch the game. How would you?
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Re: Help change skin with application

Post by maxwell1 »

Balala thank you so much once again ! You are a life saver and really good at explainations ! I will try all of this as soon as I finish my animation for the gifs! I'll tell you how it goes right after ! Thanks again !
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Re: Help change skin with application

Post by maxwell1 »

Alright so, I tried to modify the code as you recommanded and I figured I might as well delete an action (only have 3 action : play, stand and pubg instead of four to make it a little bit easier). By doing that, I managed to load the skin, go through all 3 gifs by right clicking the skin and when I tried to open the application, nothing changed on the skin. Then I realised that I didn't change the actions in the measure process to the correct numbers. Once done, I tried to open it once again and same, nothing changed except that now, I can not see anymore the pubg gif by rightclicking the skin and nothing change either.

Here's what my code looks like at the moment (not too sure about the way ./code works on this sorry if this doesn't display proprely)

Code: Select all

[Rainmeter]

Update=100


RightMouseUpAction=[!WriteKeyValue Variables Action1 #Action2#][!WriteKeyValue Variables Action2 #Action3#][!WriteKeyValue Variables Action3 #Action1#][!Refresh]

[Variables]
@Include=#@#\Variables.inc
Orientation1=Left
Orientation2=Right
Action1=Stand
Action2=Play
Action3=Pubg

[Metadata]
Author=BloodyKuma
Version=1.4.3
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=A little bear. |RMB=Change Normal Dog/Endogeny
Preview=Preview.png

[MeasureBackgroundFrameCalc]
Measure=Calc
Formula=Counter % 8
Substitute=".00000":""
Disabled=0
DynamicVariables=1

[MeterBackgroundFrame]
Meter=Image
X=0
Y=0
ImageName="#SKINSPATH#BKtest\@Resources\Images\Annoying Dog\#Action1#.\#Action1#[measureBackgroundFrameCalc].png"
DynamicVariables=1

[MeasureProcess]
Measure=Plugin
Plugin=Process
ProcessName=D:\Program Files\Games\Steam\steamapps\common\PUBG\TslGame\Binaries\Win64\TslGame.exe
Substitute="-1":"not running","1":"running"
IfCondition=(#CURRENTSECTION#>0)
IfTrueAction=[!WriteKeyValue Variables Action1 "#Action3#"]
IfFalseAction=[!WriteKeyValue Variables Action3 "#Action1#"]
Last edited by balala on April 26th, 2019, 6:06 am, edited 1 time in total.
Reason: Please use <code> tags, not </Snippet>, whever you're posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help change skin with application

Post by balala »

maxwell1 wrote: April 25th, 2019, 10:24 pm You are a life saver and really good at explainations !
Am I? I'm glad if you think so, because English is not my native language.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help change skin with application

Post by balala »

maxwell1 wrote: April 25th, 2019, 11:07 pm Alright so, I tried to modify the code as you recommanded and I figured I might as well delete an action (only have 3 action : play, stand and pubg instead of four to make it a little bit easier). By doing that, I managed to load the skin, go through all 3 gifs by right clicking the skin and when I tried to open the application, nothing changed on the skin. Then I realised that I didn't change the actions in the measure process to the correct numbers. Once done, I tried to open it once again and same, nothing changed except that now, I can not see anymore the pubg gif by rightclicking the skin and nothing change either.
First the ProcessName option of the [MeasureProcess] measure is wrong, because you don't have to enter the full path of the file, but the name of the process instead. This can be the same as the name of executable file, but not always (I hope I'm not mistaken here). But anyway, not the full path, because it has to be a process, not a file.
Also, if you don't want to use anywhere else the value returned by the [MeasureProcess] measure (as I think at least from the posted piece of code), you don't have to add a Substitute option. Simply don't needed.
Unfortunately I can't help more then this, because I'd need to test the code, but I can't without the included files (as said Variables.inc and the images). For further help, please pack the whole config and upload it.
maxwell1
Posts: 9
Joined: March 28th, 2019, 8:22 pm

Re: Help change skin with application

Post by maxwell1 »

balala wrote: April 26th, 2019, 6:08 am Am I? I'm glad if you think so, because English is not my native language.
Nah don't worry you're doing great I think! Mine must not be the best english either (I'm French)

Anyway no problem, you helped me a lot and I think I understood a little bit more how it works thanks to you so once again thank you very much ! :D
Oh and if you want I can send you the .zip file just tell me how and I'll do it !