It is currently March 28th, 2024, 3:25 pm

Sauver une mesure dans une variable - Save a measure in a variable

Get help with creating, editing & fixing problems with skins
User avatar
NoWay_To_HeaVeN
Posts: 42
Joined: December 19th, 2011, 12:28 pm
Location: FR

Sauver une mesure dans une variable - Save a measure in a variable

Post by NoWay_To_HeaVeN »

Je suis en train de tester la possibilité d'utiliser Rainmeter comme MultiMonitor Wallpaper cycler.
(Zpos=-2 sur le bureau / Clique à travers / Non déplaçable)
[Peut-être que je réinvente la roue, mais je voudrais bien trouver]
Je voudrai récupérer la valeur du nombre de moniteurs dans une variable, mais, je n'arrive pas à copier la valeur "%1" de la mesure de ce code.
Quelqu'un pourrait m'aider ?
Est-ce seulement possible ?

NB: Je sais que Rainmeter n'est pas prévu pour ce genre de chose.
-------------
I am trying to test the possibility of using Rainmeter as a MultiMonitor Wallpaper cycler.
(Zpos = -2 on the desktop / Click through / Not movable)
[Maybe I reinvent the wheel, but I would love to find]
I will want to retrieve the value of the number of monitors in a variable, but, I cannot copy the value "% 1" from the measurement from this code.
Could someone help me?
Is it even possible?

NB: I know Rainmeter is not designed for this kind of thing.

Code: Select all

[MeasureNumMonitor]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NUM_MONITORS

[MeterNumMonitor]
Meter=String
MeasureName=MeasureNumMonitor
X=0
Y=2R
Text=Screen: Activ %1
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by balala »

NoWay_To_HeaVeN wrote: January 14th, 2021, 12:02 pm I will want to retrieve the value of the number of monitors in a variable, but, I cannot copy the value "% 1" from the measurement from this code.
Could someone help me?
Is it even possible?
Yep, it definitely is. However I'm not sure where would you like to put the bang to copy the desired value, but:
  • If you want to have it on the measure, add the following option to the [MeasureNumMonitor] measure: OnUpdateAction=[!SetVariable NumMon "[MeasureNumMonitor]"]. Note that this is a not too lucky way, because since the measure is updated on each update cycle of the skin, you'll get copied the number once per second, which means you won't be able to copy anything else in the clipboard, because anytime you copy anything else, after at most one second, the previously coped value will be replaced by the number of monitors. A solution would be to add an UpdateDivider=-1 option, which seems to be a good solution, especially that usually the number of monitors doesn't change over using the skin, so not get the measure never updated, is a quite good approach, I think.
  • If you'd like to get the number copied only when you click the [MeterNumMonitor] meter, add a similar option to the meter: LeftMouseUpAction=[!SetVariable NumMon "[MeasureNumMonitor]"]. If you choose this solution, you have to click the meter, to get the number copied. Note again that if you set the skin to ClickThrough, this solution doesn't help too much, because you'll have to hold down Ctrl when you click the meter, to get copied the value.
In both cases you'll get the number of monitors copied into the NumMon variable. Make sure to use a DynamicVariables=1 option on any meter or measure where you do want to use the variable.
User avatar
NoWay_To_HeaVeN
Posts: 42
Joined: December 19th, 2011, 12:28 pm
Location: FR

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by NoWay_To_HeaVeN »

Thank you very much Balala.
I'm going to test this option.
Another question, rather than "OnUpdateAction", would there be a detection solution once when the Rainmeter is launched?
The detection of the number of connected monitors is only done once at startup, and / or if the user deactivates, then reactivates a monitor, and in this case, it is up to him to refresh the value.

I would actually plan a user action with:

Code: Select all

LeftMouseUpAction = [! SetVariable NumMon "[MeasureNumMonitor]"]
Edit: Regarding the one-time detection, sorry, I misread the UpdateDivider = -1
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by balala »

NoWay_To_HeaVeN wrote: January 14th, 2021, 8:57 pm Another question, rather than "OnUpdateAction", would there be a detection solution once when the Rainmeter is launched?
The detection of the number of connected monitors is only done once at startup, and / or if the user deactivates, then reactivates a monitor, and in this case, it is up to him to refresh the value.
No, there isn't I suppose. An OnChangeAction probably would be much better, but this has another problem: according to the manual:
The initial change from "nothing" to a value when the skin is loaded or refreshed is ignored.
which means that when you refresh the skin, it won't set the variable, which will be done only later, when the number changes.
Here sorry, I made a mistake, believing that the number of monitors doesn't change. But reading your reply I realized it might change.
Now re-reading my previous reply, I realized I made a brute mistake: when I initially wrote my code I wanted to copy the number to clipboard, then realized you want to store it into a variable. But forgot to remove the lines which I stroke out in meantime. Sorry about that.
So I suppose the best solution is to add an OnUpdateAction option, as described previously. No need for UpdateDivider=-1.
User avatar
NoWay_To_HeaVeN
Posts: 42
Joined: December 19th, 2011, 12:28 pm
Location: FR

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by NoWay_To_HeaVeN »

Your "OnUpdateAction" solution works wonderfully.
In fact, I need to know the number of connected monitors because windows assigns undetected monitors,
so the variable # SCREENAREAWIDTH @ n # repeats once monitor "4" [Mon5] (connected to video card 2),
and, at The infinite monitor 1 [Mon6 / 7 / 8...](Primary monitor, connected to video card 1),
so I must specify to the script that any value greater than NumMon is to be ignored, and return to the primary monitor.

As the capture shows, my primary is framed by monitors 2 on the right and 3/4 on the left.
I'm thinking of making the "Wallpaper" placements ScrollUp -> Left / ScrullDown -> Right ...
and if I can, the output of the leftmost monitor would revert to the rightmost one, and vice versa ...
rainmeter_windetectmonitors.PNG
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by balala »

NoWay_To_HeaVeN wrote: January 14th, 2021, 10:24 pm In fact, I need to know the number of connected monitors because windows assigns undetected monitors,
so the variable # SCREENAREAWIDTH @ n # repeats once monitor "4" [Mon5] (connected to video card 2),
and, at The infinite monitor 1 [Mon6 / 7 / 8...](Primary monitor, connected to video card 1),
so I must specify to the script that any value greater than NumMon is to be ignored, and return to the primary monitor.

As the capture shows, my primary is framed by monitors 2 on the right and 3/4 on the left.
I'm thinking of making the "Wallpaper" placements ScrollUp -> Left / ScrullDown -> Right ...
and if I can, the output of the leftmost monitor would revert to the rightmost one, and vice versa ...rainmeter_windetectmonitors.PNG
Albeit I can't try it, because i have one single monitor, I suppose all these are possible. If you have a code and want, please post it for further help.
User avatar
NoWay_To_HeaVeN
Posts: 42
Joined: December 19th, 2011, 12:28 pm
Location: FR

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by NoWay_To_HeaVeN »

balala wrote: January 15th, 2021, 7:46 am Albeit I can't try it, because i have one single monitor, I suppose all these are possible. If you have a code and want, please post it for further help.
Of course, I'll post the rmskin (not optimized, I'm not a rainmeter pro, just doing my best :confused: )
the first reason is sharing :) ,
the second is that I learned a lot by dissecting the scripts that I used in order to arrange them for my use :Whistle .
Mainly from Eclectic-tech, and ... Balala, among others ... :welcome:
And finally, because I use a lot of code that I haven't produced and often just adapted. :oops:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by balala »

NoWay_To_HeaVeN wrote: January 15th, 2021, 10:22 am Of course, I'll post the rmskin (not optimized, I'm not a rainmeter pro, just doing my best :confused: )
Still not posted...
User avatar
NoWay_To_HeaVeN
Posts: 42
Joined: December 19th, 2011, 12:28 pm
Location: FR

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by NoWay_To_HeaVeN »

balala wrote: January 15th, 2021, 7:12 pm Still not posted...
Wait, please, wait... ;-)
I'm not as good as you, among other people ...
I have already finished the cycler, I move from one screen to another without a problem,
and from the leftmost screen to the rightmost screen and vice versa.
(I just finished the function after many rainmeter crashes :oops: )

Here is the code that moves the selected wallpaper (1 screen) to the desired screen.
(I still have a lot of work to integrate the other functions,
which I had already implemented but with a movement of the "windows" with the mouse, but I am moving forward ...)

Code: Select all

[MeasureNumMonitor]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NUM_MONITORS
OnUpdateAction=[!SetVariable MaxMon1 "[MeasureNumMonitor]"]
DynamicVariables=1
UpdateDivider=-1

[MonMeasureOne]
Measure=Calc
Formula=7

[MonMeasureTwo]
Measure=Calc
Formula=MonMeasureOne < 1 ? 0 : 7
 IfCondition=(#AssignMon1# <= 0)
 IfTrueAction=[!WriteKeyValue "Variables" AssignMon1 "4" ][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "LoadOrder" "1" "#SETTINGSPATH#Rainmeter.ini"][!Refresh "#ROOTCONFIG#\Divers\Wallpaper_testpos"]
 IfCondition2=(#AssignMon1# >= 1) && (#AssignMon1# < 2)
 IfTrueAction2=[!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowX" "(0 + #SCREENAREAWIDTH#)" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowY" "1" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "LoadOrder" "1" "#SETTINGSPATH#Rainmeter.ini"]
 IfCondition3=(#AssignMon1# >= 2) && (#AssignMon1# < 3)
 IfTrueAction3=[!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowX" "0" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowY" "1" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "LoadOrder" "1" "#SETTINGSPATH#Rainmeter.ini"]
 IfCondition4=(#AssignMon1# >= 3) && (#AssignMon1# < 4)
 IfTrueAction4=[!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowX" "(0 - #SCREENAREAWIDTH@3#)" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowY" "1" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "LoadOrder" "1" "#SETTINGSPATH#Rainmeter.ini"]
 IfCondition5=(#AssignMon1# >= 4) && (#AssignMon1# < 5)
 IfTrueAction5=[!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowX" "(0 - (#SCREENAREAWIDTH@3# + #SCREENAREAWIDTH@4#))" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "WindowY" "1" "#SETTINGSPATH#Rainmeter.ini"][!WriteKeyValue "RSP_interface\Divers\Wallpaper_testpos" "LoadOrder" "1" "#SETTINGSPATH#Rainmeter.ini"]
 IfCondition6=(#AssignMon1# > #MaxMon1#)
 IfTrueAction6=[!WriteKeyValue "Variables" AssignMon1 "1" ][!Refresh "#ROOTCONFIG#\Divers\Wallpaper_testpos"]
 OnUpdateAction=[!UpdateMeter MonitorInfos][!Redraw]
DynamicVariables=1 
I use this cycler for other functions, I don't think I put it in the rmskin already posted ...
Thank you again, because without you, the cycler would have caused a lot of problems :thumbup: ...

Edit : Ooops, I forgot to specify, but you must note it in this code, that the wallpapers will not be resolution dependent,
but adapted if this one changes during the Windows session.

Edit II:The loadorder = 1 is for testing purposes, I will change it to -5 in the distributed version,
and the 1px from top, is related to the fact that if the taskbar is at the top (which is the case with me) it is covered by the wallpaper
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Sauver une mesure dans une variable - Save a measure in a variable

Post by balala »

NoWay_To_HeaVeN wrote: January 15th, 2021, 9:37 pm Here is the code that moves the selected wallpaper (1 screen) to the desired screen.
As said, I have one single monitor, so I suppose it is harder for me to test your code, however I have a question related to the posted code: the value of the [MonMeasureOne] measure is ALWAYS 7, so accordingly, the value of the [MonMeasureTwo] measure is always 7 as well. I don't see so far any exception of this rule. Am I mistaken?
Post Reply