It is currently March 28th, 2024, 5:39 pm

Update skin after closing a program

Get help with creating, editing & fixing problems with skins
User avatar
LazieWouters
Posts: 61
Joined: August 29th, 2021, 11:11 am

Update skin after closing a program

Post by LazieWouters »

Hi friends,

I created a small executable in C# which opens the ColorDialog window, so that it is easier for the user to choose the desired color.
Through the Settings window I call the executable, which will overwrite the variable that stores the color value.
Everything is working fine, except that the skin is not automatically updated after the ColorDialog has been closed.

I tried as follows with FinishAction but it doesn't work. Is there any way?

Code: Select all

[MeterBackgroundColorDialog]
Meter=Image
ImageName=#@#code.png
X=310
Y=-5r
AntiAlias=1
LeftMouseUpAction=!Execute ["#@#ColorDialog_myWeather.exe" "BackgroundColor="]
FinishAction=!Execute [!Refresh][!Refresh "#ROOTCONFIG#\Weather"][!Refresh "#ROOTCONFIG#\Settings"][!Refresh "#ROOTCONFIG#"]
And I would also like to know if having an executable made in another program allows me to put the skin on the Deviant Art website or not?


Untitled-1.png
Thanks
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Update skin after closing a program

Post by jsmorley »

FinishAction is only applicable to measures and plugins that are coded to specifically react to a FinishAction option on the measure. It is treated just like any other option, and should be read when the measure or plugin is initialized (Reload). Then some action can be taken as desired, logically as one of the last things executed when the current update cycle of the measure or plugin is completed.

Think of it like this:

1) During the Reload() function specifically check to see if there is a FinishAction option. Read the option so you know what will be expected to be done.
2) Do all the normal work that your plugin is going to do in the Update() function.
3) At the end of the Update() function, just before you call return to exit the plugin for that cycle, take whatever action is defined in FinishAction.

The long and the short of it is that FinishAction is not a built-in or in any way automatic function. It must be specifically coded for.

Since your external C# application is not a measure or plugin, I think you will need to have it use the command line to tell Rainmeter to refresh either the skin or all of Rainmeter when it is done getting and setting the color.

As to deviantART, sure. As long as the submission is contained in a valid .rmskin.

Please stop using !Execute. It was deprecated years ago, and is no longer needed.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Update skin after closing a program

Post by balala »

EDIT: Sorry jsmorley...
LazieWouters wrote: October 9th, 2021, 11:37 am I tried as follows with FinishAction but it doesn't work. Is there any way?

Code: Select all

[MeterBackgroundColorDialog]
Meter=Image
ImageName=#@#code.png
X=310
Y=-5r
AntiAlias=1
LeftMouseUpAction=!Execute ["#@#ColorDialog_myWeather.exe" "BackgroundColor="]
FinishAction=!Execute [!Refresh][!Refresh "#ROOTCONFIG#\Weather"][!Refresh "#ROOTCONFIG#\Settings"][!Refresh "#ROOTCONFIG#"]
FinishAction can't be used on meters, only on measures. And neither there not on all of them. It can be used for instance on parent WebParser or FileView measures or on RunCommand plugin measures. But definitely can't be used on meters. Neither on Image meters, nor on any other type of meters.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: Update skin after closing a program

Post by death.crafter »

LazieWouters wrote: October 9th, 2021, 11:37 am Hi friends,

I created a small executable in C# which opens the ColorDialog window, so that it is easier for the user to choose the desired color.
Through the Settings window I call the executable, which will overwrite the variable that stores the color value.
Everything is working fine, except that the skin is not automatically updated after the ColorDialog has been closed.

I tried as follows with FinishAction but it doesn't work. Is there any way?

Code: Select all

[MeterBackgroundColorDialog]
Meter=Image
ImageName=#@#code.png
X=310
Y=-5r
AntiAlias=1
LeftMouseUpAction=!Execute ["#@#ColorDialog_myWeather.exe" "BackgroundColor="]
FinishAction=!Execute [!Refresh][!Refresh "#ROOTCONFIG#\Weather"][!Refresh "#ROOTCONFIG#\Settings"][!Refresh "#ROOTCONFIG#"]
And I would also like to know if having an executable made in another program allows me to put the skin on the Deviant Art website or not?
A few options:
  • Since you are making an executable in C#, here is a trick, use temporary variables.

    Take in two arguments,
    • Path to Rainmeter
    • A bang with temporary variables, e.g. $color$
    Now in your button event handler you can do,

    Code: Select all

    Process rainmeter = newProcess();
    rainmeter.StartInfo.FileName = args[0];
    rainmeter.StartInfo.Arguments = args[1].Replace("$color$", yourColorVar.ToString());
    rainmeter.Start();
    
    But here, you have to use #CURRENTCONFIG# or ConfigName parameter with every bang where it is applicable. But it will be dynamic, e.g. you are not limited to variables and free to update and redraw.

    Example usage:

    Code: Select all

    [Variables]
    ColorChangeBang = [!SetVariable ThisColor \"$color$\" \"CURRENTCONFIG\"][!WriteKeyValue Variables ThisColor \"$color$\" \"#CURRENTPATH##CURRENTFILE#\"][!Update \"#CURRENTCONFIG#\"]
    [SomeMeter]
    ...
    LeftMouseUpAction = ["#@#myColorPicker.exe" "#PROGRAMPATH#Rainmeter.exe" "#ColorChangeBang#"]
    
    Notice the usage of \" here as you have to escape literal double quotes.
  • Use RainRGB by jsmorley. But personally, I wouldn't suggest it because sometimes av's flag it as malware or something as it is made using autohotkey.
  • Use rainmeter color pickers. You can find them in Share your creations section.
    Speaking of which I got a chance to advertise my skin :twisted:
    ColorPickerUI
Last edited by death.crafter on October 9th, 2021, 12:55 pm, edited 1 time in total.
User avatar
LazieWouters
Posts: 61
Joined: August 29th, 2021, 11:11 am

Re: Update skin after closing a program

Post by LazieWouters »

Hello jsmorley and balala

Thank you very much! I read your comment and started looking for command line on the forum, and then I found this post:
https://docs.rainmeter.net/manual/bangs/
in which it explains that it is possible to execute commands through the Windows command prompt, like this:
"C:\Program Files\Rainmeter\Rainmeter.exe" !RefreshApp
which is exactly the command I need to refresh the skin.
I changed it a little, like this:

Code: Select all

ExecuteCommand("\"C:\\Program Files\\Rainmeter\\Rainmeter.exe\" !RefreshApp");

void ExecuteCommand(string Command)
{
	ProcessStartInfo ProcessInfo;
	Process Process;

	ProcessInfo = new ProcessStartInfo("cmd.exe", "/K " + Command);
	ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
	ProcessInfo.CreateNoWindow = true;
	ProcessInfo.UseShellExecute = true;

	Process = Process.Start(ProcessInfo);
}
...to run it directly from the C# executable. It's working, thank you very much. In a little while I will post the updated skin.
Please stop using !Execute. It was deprecated years ago, and is no longer needed.
OK, I removed them all now.

Thank you again!
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: Update skin after closing a program

Post by death.crafter »

LazieWouters wrote: October 9th, 2021, 12:54 pm Hello jsmorley and balala

Thank you very much! I read your comment and started looking for command line on the forum, and then I found this post:
https://docs.rainmeter.net/manual/bangs/
in which it explains that it is possible to execute commands through the Windows command prompt, like this:
"C:\Program Files\Rainmeter\Rainmeter.exe" !RefreshApp
which is exactly the command I need to refresh the skin.
I changed it a little, like this:

Code: Select all

ExecuteCommand("\"C:\\Program Files\\Rainmeter\\Rainmeter.exe\" !RefreshApp");

void ExecuteCommand(string Command)
{
	ProcessStartInfo ProcessInfo;
	Process Process;

	ProcessInfo = new ProcessStartInfo("cmd.exe", "/K " + Command);
	ProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
	ProcessInfo.CreateNoWindow = true;
	ProcessInfo.UseShellExecute = true;

	Process = Process.Start(ProcessInfo);
}
...to run it directly from the C# executable. It's working, thank you very much. In a little while I will post the updated skin.


OK, I removed them all now.

Thank you again!
I wouldn't recommend doing this.

!RefreshApp refreshes all the configs currently active, which may cause unwanted behaviour, e.g. some skin's progress being lost etc, since you will be distributing the skin.
User avatar
LazieWouters
Posts: 61
Joined: August 29th, 2021, 11:11 am

Re: Update skin after closing a program

Post by LazieWouters »

death.crafter wrote: October 9th, 2021, 12:58 pm I wouldn't recommend doing this.

!RefreshApp refreshes all the configs currently active, which may cause unwanted behaviour, e.g. some skin's progress being lost etc, since you will be distributing the skin.
Hum, ok

I will replace to this [!Refresh "#ROOTCONFIG#\Weather"][!Refresh "#ROOTCONFIG#\Settings"][!Refresh "#ROOTCONFIG#"] to refresh just the skins that need be updated
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Update skin after closing a program

Post by jsmorley »

I agree with death.crafter in principle, although it could be argued that the user isn't going to be changing the color(s) all that often.

While it is a tad less flexible, I'd probably either pass the config to refresh as part of the command line to the C# application, or hard-code the config to refresh, and then use something like:

"C:\Program Files\Rainmeter\Rainmeter.exe" !Refresh "MyConfig"
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm
Contact:

Re: Update skin after closing a program

Post by death.crafter »

LazieWouters wrote: October 9th, 2021, 1:02 pm Hum, ok

I will replace to this [!Refresh "#ROOTCONFIG#\Weather"][!Refresh "#ROOTCONFIG#\Settings"][!Refresh "#ROOTCONFIG#"] to refresh just the skins that need be updated
That actually wouldn't work.

Rainmeter.exe doesn't know what #ROOTCONFIG# is.

You can look at the first option given in my first reply here to do what you want to do efficiently.

https://forum.rainmeter.net/viewtopic.php?p=198756#p198756
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Update skin after closing a program

Post by jsmorley »

You might want to consider !RefreshGroup if you need to refresh multiple configs.

https://docs.rainmeter.net/manual/bangs/#RefreshGroup
Post Reply