It is currently April 16th, 2024, 4:59 am

[SOLVED] Detect skin visibility/load status

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

[SOLVED] Detect skin visibility/load status

Post by Yincognito »

Is there an easy way (or a way, nevertheless) to detect if a skin is shown/hidden and if it's loaded/unloaded? The only way I can think of to achieve that (and that's only for the load/unload status) is to somehow parse Rainmeter.ini using either WebParser or an @include and check for Active=1 lines for the skin in question. This method is questionable though (who knows what happens when you @include Rainmeter.ini in your skin?) and, of course, I can't see a way of detecting a skin's visibility...

Bottom line, my suite of skins if made of around 13 or 14 skins and I'd like to make a "toggler" skin so that I can easily show/hide or load/unload all the other skins in the suite. This part is easy to do, but I want to also show to the user the status of the skins in question, e.g. "visible", "hidden" or "unloaded", so I need to get that status from somewhere.
Last edited by Yincognito on March 27th, 2019, 11:29 pm, edited 2 times in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Detect skin visibility/load status

Post by StArL0rd84 »

JSMorley and TheAzack9 made a plugin a while back that can check if skins are loaded or not.
https://forum.rainmeter.net/viewtopic.php?f=127&t=28720&hilit=configactive
Last edited by StArL0rd84 on March 26th, 2019, 4:40 pm, edited 2 times in total.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Detect skin visibility/load status

Post by eclectic-tech »

Yincognito wrote: March 26th, 2019, 4:28 pm Is there an easy way (or a way, nevertheless) to detect if a skin is shown/hidden and if it's loaded/unloaded? The only way I can think of to achieve that (and that's only for the load/unload status) is to somehow parse Rainmeter.ini using either WebParser or an @include and check for Active=1 lines for the skin in question. This method is questionable though (who knows what happens when you @include Rainmeter.ini in your skin?) and, of course, I can't see a way of detecting a skin's visibility...

Bottom line, my suite of skins if made of around 13 or 14 skins and I'd like to make a "toggler" skin so that I can easily show/hide or load/unload all the other skins in the suite. This part is easy to do, but I want to also show to the user the status of the skins in question, e.g. "visible", "hidden" or "unloaded", so I need to get that status from somewhere.
This may help: LoadSkin by raiguard
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Detect skin visibility/load status

Post by Yincognito »

Well, yeah - the links you both posted are surely helpful, thank you both. What about the hidden status though?

Having said that, do you know of alternative methods that don't require additional plugins or LUA?
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Detect skin visibility/load status

Post by eclectic-tech »

Yincognito wrote: March 26th, 2019, 4:58 pm Well, yeah - the links you both posted are surely helpful, thank you both. What about the hidden status though?

Having said that, do you know of alternative methods that don't require additional plugins or LUA?
A hidden skin will have a zero height value (#CURRENTCONFIGHEIGHT#) which you may be able to use to detect the visibility of an active skin (haven't taken the time to look much further).

Parsing Rainmeter.ini and testing for ACTIVE > 0 is probably the simplest way to determine loaded/unloaded. Using raiguards lua script combines a number of checks all together, which for me, seems to be the best current solution for what you are attempting.

I can not think of a solution that would not be just a collection of measures trying to do what raiguard's lua script can do for you. You can "re-invent the wheel" if you want, but I would not disregard lua scripts simply becasue they are not "native" rainmeter; lua is a great supplement to Rainmeter and simplifies doing many processes that are either cumbersome or impossible in Rainmeter.
User avatar
balala
Rainmeter Sage
Posts: 16141
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Detect skin visibility/load status

Post by balala »

eclectic-tech wrote: March 26th, 2019, 6:04 pm Parsing Rainmeter.ini and testing for ACTIVE > 0 is probably the simplest way to determine loaded/unloaded. Using raiguards lua script combines a number of checks all together, which for me, seems to be the best current solution for what you are attempting.

I can not think of a solution that would not be just a collection of measures trying to do what raiguard's lua script can do for you. You can "re-invent the wheel" if you want, but I would not disregard lua scripts simply becasue they are not "native" rainmeter; lua is a great supplement to Rainmeter and simplifies doing many processes that are either cumbersome or impossible in Rainmeter.
The ConfigActive plugin has many advantages. I recommend always using it instead of parsing Rainmeter.ini: https://forum.rainmeter.net/viewtopic.php?f=122&t=28688&p=149595&hilit=configactive#p149595
No need of lua scripts. Don't misunderstand me, I don't say the lua solution isn't good enough, but probably the plugin is even better. My opinion, at least...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Detect skin visibility/load status

Post by jsmorley »

eclectic-tech wrote: March 26th, 2019, 6:04 pm A hidden skin will have a zero height value (#CURRENTCONFIGHEIGHT#) which you may be able to use to detect the visibility of an active skin (haven't taken the time to look much further).

This is not actually the case. Meters are "hidden" by setting their W and H to zero. This is not true of entire skin windows. Skin are hidden by changing an attribute of the "window" to a hidden state. If you hide a skin, it will continue to have the W and H (for purposes of #CURRENTCONFIGWIDTH#) it would have if it was not hidden.

I'm not sure I can think of an easy way to test if a Rainmeter skin "window" is in a hidden state.

It's a bit complicated to get outside of some C++ / C# plugin really, as Rainmeter skins are "windows", but in some ways not in the traditional sense of an normal application window. There is no "Title", and the "Class" is the same for all running skins. So isolating the skin in question in order to get the numeric window "handle" is a bit tricky. You have to actually "ask" Rainmeter for the window handle for a particular "config name" using SendMessage, then you could use that handle to get the state of the skin window.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Detect skin visibility/load status

Post by eclectic-tech »

jsmorley wrote: March 26th, 2019, 6:46 pm This is not actually the case. Meters are "hidden" by setting their W and H to zero. This is not true of entire skin windows. Skin are hidden by changing an attribute of the "window" to a hidden state. If you hide a skin, it will continue to have the W and H (for purposes of #CURRENTCONFIGWIDTH#) it would have if it was not hidden.

I'm not sure I can think of an easy way to test if a Rainmeter skin "window" is in a hidden state.

It's a bit complicated to get outside of some C++ / C# plugin really, as Rainmeter skins are "windows", but in some ways not in the traditional sense of an normal application window. There is no "Title", and the "Class" is the same for all running skins. So isolating the skin in question in order to get the numeric window "handle" is a bit tricky. You have to actually "ask" Rainmeter for the window handle for a particular "config name" using SendMessage, then you could use that handle to get the state of the skin window.
Yeah, I was thinking "meter" and wasn't sure if the same applied to skins... Thanks for the correction.

I think the best method, without needing to test if a skin is hidden or not, would be to use !ToggleConfig Configname, which will load/unload the skin regardless of it's current state.
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Detect skin visibility/load status

Post by Yincognito »

eclectic-tech wrote: March 26th, 2019, 6:04 pmA hidden skin will have a zero height value (#CURRENTCONFIGHEIGHT#) which you may be able to use to detect the visibility of an active skin (haven't taken the time to look much further).
Good idea, but I'm attempting to do this from another skin in the suite, so, unless you know a way to get the #CONFIGHEIGHT# of another skin than the current one, this doesn't seem to quite cut it.
eclectic-tech wrote: March 26th, 2019, 6:04 pmI can not think of a solution that would not be just a collection of measures trying to do what raiguard's lua script can do for you. You can "re-invent the wheel" if you want, but I would not disregard lua scripts simply becasue they are not "native" rainmeter; lua is a great supplement to Rainmeter and simplifies doing many processes that are either cumbersome or impossible in Rainmeter.
balala wrote: March 26th, 2019, 6:11 pmThe ConfigActive plugin has many advantages. I recommend always using it instead of parsing Rainmeter.ini: https://forum.rainmeter.net/viewtopic.php?f=122&t=28688&p=149595&hilit=configactive#p149595
No need of lua scripts. Don't misunderstand me, I don't say the lua solution isn't good enough, but probably the plugin is even better. My opinion, at least...
It's not about reinventing the wheel, not wanting to use a plugin or disregarding Lua at all. It's first about the fact that I always try to minimize dependencies in everything I code, not just in Rainmeter (that's why I'm glad plugins like UsageMonitor or WebParser became "official"/"native" in Rainmeter recently). Secondly, as an amateur programmer, using Lua to do what I could do in Rainmeter code (and this could be done, probably, albeit in a less orthodox fashion) makes Rainmeter seems a bit obsolete - I mean, if I wanted to use a programming environment to build my skins, I would have done it right from the start in C#, Delphi or Lazarus and wouldn't have used Rainmeter at all. I don't know if you understand what I'm saying here or if you agree, but using Lua to do things feels to me like using some C code to do things that Rainmeter (also written in C) could probably do as well, if approached the right way. One of the reasons I made my own text calendar based on the Zeller's congruence instead of using an already made Lua calendar instead. Just my opinion, feel free to disagree.
---------------
Anyway, I was looking for ways to get these statuses just to "fill" my toogler skin tooltip with something and displaying the status of the skins I was toggling seemed like a good filler there, since that was all the toggler skin was about. I guess I could live without it - after all, the user can easily see their status anyway, and doesn't necessarily need some info text to tell him the obvious. I could also probably do this by writing in an .inc the appropriate bangs or variables that indicate these statuses after setting them in the OnRefreshAction option of every skin in the suite, then @include that .inc in the toggler skin, but I'll have to weigh in which way to go with this. Bottom line, any way would be a good one, as the thing isn't critical - it was just a matter of making stuff look more fancy.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7118
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Detect skin visibility/load status

Post by Yincognito »

eclectic-tech wrote: March 26th, 2019, 7:20 pmI think the best method, without needing to test if a skin is hidden or not, would be to use !ToggleConfig Configname, which will load/unload the skin regardless of it's current state.
Yeah, that's the way I am doing it. Funny thing, eh: the ToggleConfig bang "knows" whether the skin is hidden or not (since it successfully toggles that state), it's just that there isn't an easy way to let the user know about it... :lol:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth