It is currently March 28th, 2024, 11:56 am

[Trick | Guide] Simple scrolling switcher

Tips and Tricks from the Rainmeter Community
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City
Contact:

[Trick | Guide] Simple scrolling switcher

Post by deflore08 »

Hey there! Today i want to tell you how to make an easy scrolling-switcher. You can use this everywhere where you know a count of possible values. As example i will work with players array. It is a big trouble for some users to look inside your code and input a player name manually. Let's see how we can solve this.

Видео 16-09-2020 19_52_12.gif

For the first we should define some conformity. As we know, NowPlaying plugin support 8 types of players: AIMP, CAD, iTunes, MediaMonkey, WinAmp, WMP, Spotify, WLM. The list is here. So we can make next conformity: 1 = AIMP, 2 = CAD, 3 = iTunes etc. We need 2 variables for this. Let's make it:

Code: Select all

[Variables]
Player_Name=
Player_Selection=0
After this we should invent something what will do a dirty job for us - to equal a values and set variable #Player_Name# depending on #Player_Selection# variable. It's pretty simple task with a Calc measure:

Code: Select all

[f.Player_Selection]
Measure=Calc
DynamicVariables=1
ifCondition=#Player_Selection# < 1
ifTrueAction=[!SetVariable Player_Selection "8"][!WriteKeyValue Variables Player_Selection "8" "Switcher.ini"][!SetVariable Player_Name "AIMP"][!WriteKeyValue Variables Player_Name "AIMP" "Switcher.ini"]
ifCondition2=#Player_Selection# > 8
ifTrueAction2=[!SetVariable Player_Selection "1"][!WriteKeyValue Variables Player_Selection "1" "Switcher.ini"][!SetVariable Player_Name "WLM"][!WriteKeyValue Variables Player_Name "WLM" "Switcher.ini"]
ifCondition3=#Player_Selection# = 1
ifTrueAction3=[!SetVariable Player_Name "AIMP"][!WriteKeyValue Variables Player_Name "AIMP" "Switcher.ini"]
ifCondition4=#Player_Selection# = 2
ifTrueAction4=[!SetVariable Player_Name "CAD"][!WriteKeyValue Variables Player_Name "CAD" "Switcher.ini"]
ifCondition5=#Player_Selection# = 3
ifTrueAction5=[!SetVariable Player_Name "ITUNES"][!WriteKeyValue Variables Player_Name "ITUNES" "Switcher.ini"]
ifCondition6=#Player_Selection# = 4
ifTrueAction6=[!SetVariable Player_Name "MEDIAMONKEY"][!WriteKeyValue Variables Player_Name "MEDIAMONKEY" "Switcher.ini"]
ifCondition7=#Player_Selection# = 5
ifTrueAction7=[!SetVariable Player_Name "WINAMP"][!WriteKeyValue Variables Player_Name "WINAMP" "Switcher.ini"]
ifCondition8=#Player_Selection# = 6
ifTrueAction8=[!SetVariable Player_Name "WMP"][!WriteKeyValue Variables Player_Name "WMP" "Switcher.ini"]
ifCondition9=#Player_Selection# = 7
ifTrueAction9=[!SetVariable Player_Name "SPOTIFY"][!WriteKeyValue Variables Player_Name "SPOTIFY" "Switcher.ini"]
ifCondition10=#Player_Selection# = 8
ifTrueAction10=[!SetVariable Player_Name "WLM"][!WriteKeyValue Variables Player_Name "WLM" "Switcher.ini"]
We just checking the current value of #Player_Selection# var and set #Player_Name# depending on the last one. If we do not want to reset our settings after refreshing or reloading a skin, we should write value to file, so we use !WriteKeyValue, and !SetVariable to change it on a flight.
But we still need something what will change our #Player_Selection# variable. Let's try some magic:

Code: Select all

[t.Scroll_Example]
Meter=String
Y=80
X=0
W=200
H=40
Text="SCROLL ME"
SolidColor=100, 100, 100, 100
FontColor=200, 200, 150, 255
FontSize=24
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
MouseScrollUpAction=[!SetVariable Player_Selection "(#Player_Selection# + 1)"][!WriteKeyValue Variables Player_Selection "(#Player_Selection# + 1)" "Switcher.ini"][!Update]
MouseScrollDownAction=[!SetVariable Player_Selection "(#Player_Selection# - 1)"][!WriteKeyValue Variables Player_Selection "(#Player_Selection# - 1)" "Switcher.ini"][!Update]
As you can see, scroll up changes #Player_Selection# to (#Player_Selection# + 1) and scroll down does the same thing but it's lower the value. In our Calc measure we set conditions what says "if variable #Player_Selection# become higher than 8, i will set it to 1 and vice-versa".

All that left it is to use our #Player_Name# in NowPlaying measure. Do no forget to set DynamicVariables on:

Code: Select all

[Player]
Measure=NowPlaying
PlayerName=#Player_Name#
DynamicVariables=1
And to enjoy, of course. See you around. :)
ScrollingSwitcher_1.0.rmskin
(1.27 KiB) Downloaded 42 times

UPDATE:

Enhanced edition by balala with a beautiful scrolling effect based on ActionTimer:

GIF.gif

Code: Select all

[Metadata]
Name=PlayerSwitcher
Version=1.1
Author=balala (http://balazslaci.deviantart.com/) | deflore08 (deflore08@gmail.com)
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple switcher example

[Variables]
Player_Name=AIMP
Player_Selection=1
Player_NameUp=WLM
Player_SelectionUp=8
Player_NameDown=CAD
Player_SelectionDown=2
U=[!UpdateMeasure "MeasureScroll"][!UpdateMeasure "MeasureY"][!UpdateMeterGroup "Names"][!Redraw]
Y=0

[Background]
Meter=Image
W=200
H=150
SolidColor=0,0,0,180

; - #Player_Selection# sets player name depending on it's value from 1 to 8. (1=AIMP; 2=CAD; 3=iTunes; 4=MediaMonkey; 5=Winamp; 6=WMP; 7=Spotify; 8=WLM)

[MeasureScroll]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Up,20,10
Up=[!SetVariable Y "(Clamp((#Y#-1),-10,10))"]#U#
ActionList2=Repeat Down,20,10
Down=[!SetVariable Y "(Clamp((#Y#+1),-10,10))"]#U#
DynamicVariables=1

[MeasureY]
Measure=Calc
Formula=#Y#
IfCondition=(#CURRENTSECTION#=-10)
IfTrueAction=[!SetVariable Y "0"][!SetVariable Player_Selection "((#Player_Selection#=1)?8:(#Player_Selection#-1))"][!SetVariable Player_SelectionUp "((#Player_SelectionUp#=1)?8:(#Player_SelectionUp#-1))"][!SetVariable Player_SelectionDown "((#Player_SelectionDown#=1)?8:(#Player_SelectionDown#-1))"][!UpdateMeasure "f.Player_Selection"][!WriteKeyValue Variables Player_Selection "((#Player_Selection#=1)?8:(#Player_Selection#-1))"][!WriteKeyValue Variables Player_SelectionUp "((#Player_SelectionUp#=1)?8:(#Player_SelectionUp#-1))"][!WriteKeyValue Variables Player_SelectionDown "((#Player_SelectionDown#=1)?8:(#Player_SelectionDown#-1))"][!UpdateMeasure "f.Player_Selection"]#U#
IfCondition2=(#CURRENTSECTION#=10)
IfTrueAction2=[!SetVariable Y "0"][!SetVariable Player_Selection "((#Player_Selection#=8)?1:(#Player_Selection#+1))"][!SetVariable Player_SelectionUp "((#Player_SelectionUp#=8)?1:(#Player_SelectionUp#+1))"][!SetVariable Player_SelectionDown "((#Player_SelectionDown#=8)?1:(#Player_SelectionDown#+1))"][!WriteKeyValue Variables Player_Selection "((#Player_Selection#=8)?1:(#Player_Selection#+1))"][!WriteKeyValue Variables Player_SelectionUp "((#Player_SelectionUp#=8)?1:(#Player_SelectionUp#+1))"][!WriteKeyValue Variables Player_SelectionDown "((#Player_SelectionDown#=8)?1:(#Player_SelectionDown#+1))"][!UpdateMeasure "f.Player_Selection"]#U#
DynamicVariables=1

[f.Player_Selection]
Measure=Calc
DynamicVariables=1
IfCondition=#Player_Selection#=1
IfTrueAction=[!SetVariable Player_Name "AIMP"][!SetVariable Player_NameUp "WLM"][!SetVariable Player_NameDown "CAD"][!WriteKeyValue Variables Player_Name "AIMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WLM"][!WriteKeyValue Variables Player_NameDown "CAD"]
IfCondition2=#Player_Selection#=2
IfTrueAction2=[!SetVariable Player_Name "CAD"][!SetVariable Player_NameUp "AIMP"][!SetVariable Player_NameDown "ITUNES"][!WriteKeyValue Variables Player_Name "CAD" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "AIMP"][!WriteKeyValue Variables Player_NameDown "ITUNES"]
IfCondition3=#Player_Selection#=3
IfTrueAction3=[!SetVariable Player_Name "ITUNES"][!SetVariable Player_NameUp "CAD"][!SetVariable Player_NameDown "MEDIAMONKEY"][!WriteKeyValue Variables Player_Name "ITUNES" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "CAD"][!WriteKeyValue Variables Player_NameDown "MEDIAMONKEY"]
IfCondition4=#Player_Selection#=4
IfTrueAction4=[!SetVariable Player_Name "MEDIAMONKEY"][!SetVariable Player_NameUp "ITUNES"][!SetVariable Player_NameDown "WINAMP"][!WriteKeyValue Variables Player_Name "MEDIAMONKEY" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "ITUNES"][!WriteKeyValue Variables Player_NameDown "WINAMP"]
IfCondition5=#Player_Selection#=5
IfTrueAction5=[!SetVariable Player_Name "WINAMP"][!SetVariable Player_NameUp "MEDIAMONKEY"][!SetVariable Player_NameDown "WMP"][!WriteKeyValue Variables Player_Name "WINAMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "MEDIAMONKEY"][!WriteKeyValue Variables Player_NameDown "EMP"]
IfCondition6=#Player_Selection#=6
IfTrueAction6=[!SetVariable Player_Name "WMP"][!SetVariable Player_NameUp "WINAMP"][!SetVariable Player_NameDown "SPOTIFY"][!WriteKeyValue Variables Player_Name "WMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WINAMP"][!WriteKeyValue Variables Player_NameDown "SPOTIFY"]
IfCondition7=#Player_Selection#=7
IfTrueAction7=[!SetVariable Player_Name "SPOTIFY"][!SetVariable Player_NameUp "WMP"][!SetVariable Player_NameDown "WLM"][!WriteKeyValue Variables Player_Name "SPOTIFY" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WMP"][!WriteKeyValue Variables Player_NameDown "WLM"]
IfCondition8=#Player_Selection#=8
IfTrueAction8=[!SetVariable Player_Name "WLM"][!SetVariable Player_NameUp "SPOTIFY"][!SetVariable Player_NameDown "AIMP"][!WriteKeyValue Variables Player_Name "WLM" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "SPOTIFY"][!WriteKeyValue Variables Player_NameDown "AIMP"]

[t.Scroll_Example]
Meter=String
Y=80
X=0
W=200
H=40
Text="SCROLL ME"
SolidColor=100, 100, 100, 100
FontColor=200, 200, 150, 255
FontSize=24
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
MouseScrollUpAction=[!CommandMeasure "MeasureScroll" "Execute 1"][!CommandMeasure "MeasureScroll" "Stop 2"]
MouseScrollDownAction=[!CommandMeasure "MeasureScroll" "Stop 1"][!CommandMeasure "MeasureScroll" "Execute 2"]

[PlayerNameContainer]
Meter=Image
SolidColor=0,0,0
X=0
Y=20
W=200
H=24
UpdateDivider=-1

[t.Player_NameUp]
Meter=String
Y=(-40+2*(10-#Y#))
X=0
W=200
H=40
Text=#Player_SelectionUp#: #Player_NameUp#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names

[t.Player_Name]
Meter=String
Y=(-20+2*(10-#Y#))
X=0r
W=200
H=40
Text=#Player_Selection#: #Player_Name#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names

[t.Player_NameDown]
Meter=String
Y=(2*(10-#Y#))
X=0r
W=200
H=40
Text=#Player_SelectionDown#: #Player_NameDown#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names
ScrollingSwitcher_1.1.rmskin
(1.7 KiB) Downloaded 33 times

UPDATE:

Another solution from Yincognito. A little harder, but more reliable and protected. A bugs prevented.

Видео 21-09-2020 09_53_17.gif

Code: Select all

[Variables]
Players="AIMP,CAD,iTunes,MediaMonkey,Winamp,WMP,Spotify,WLM"
PlayerCount=8
PlayerUpIndex=6
PlayerUp=Spotify
U=[!UpdateMeasure "Scroll"][!UpdateMeter *][!Redraw]
Y=0

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=PlayerSwitcher
Version=1.2
Author= THE RAINMETER COMMUNITY AND THE HOLY SPIRIT feat balala (http://balazslaci.deviantart.com/) | Yincognito (https://www.deviantart.com/yincognyto)| deflore08 (deflore08@gmail.com)
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple switcher example

---Measures---

[Scroll]
Group=ScrollGroup
Measure=Plugin
Plugin=ActionTimer
ActionList1=UpdateUp | Wait 5 | Repeat Up,15,24 | Wait 5
Up=[!SetVariable Y (Clamp((#Y#+1),-24,0))]#U#
UpdateUp=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#-1)%#PlayerCount#)][!SetVariable Y -24][!UpdateMeasureGroup "ScrollGroup"]#U#
ActionList2=Repeat Down,15,24 | Wait 5 | UpdateDown | Wait 5
Down=[!SetVariable Y (Clamp((#Y#-1),-24,0))]#U#
UpdateDown=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)][!SetVariable Y 0][!UpdateMeasureGroup "ScrollGroup"]#U#
DynamicVariables=1

[PlayerUpIndex]
Group=ScrollGroup
Measure=Calc
Formula=(#PlayerUpIndex#)
UpdateDivider=-1
OnUpdateAction=[!WriteKeyValue Variables PlayerUpIndex [PlayerUpIndex]]
DynamicVariables=1

[PlayerUp]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerUpIndex]}(.*),.*$":"\1"
OnUpdateAction=[!WriteKeyValue Variables PlayerUp "[PlayerUp]"]
DynamicVariables=1

[PlayerDownIndex]
Group=ScrollGroup
Measure=Calc
Formula=((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)
UpdateDivider=-1
DynamicVariables=1

[PlayerDown]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerDownIndex]}(.*),.*$":"\1"
DynamicVariables=1

---Meters---

[Background]
Meter=Image
W=200
H=150
SolidColor=0,0,0,180

[Container]
Meter=Image
SolidColor=0,0,0,255
X=0
Y=20
W=200
H=24

[PlayerUpName]
Container=Container
Group=NamesGroup
Meter=String
X=10
Y=(#Y#)
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerUpIndex
MeasureName2=PlayerUp
Text="%1: %2"
DynamicVariables=1

[PlayerDownName]
Container=Container
Group=NamesGroup
Meter=String
X=0r
Y=0R
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerDownIndex
MeasureName2=PlayerDown
Text="%1: %2"
DynamicVariables=1

[ScrollText]
Meter=String
X=100
Y=80
W=200
H=40
SolidColor=100,100,100,100
FontColor=200,200,150,255
FontSize=24
FontFace=Arial
StringAlign=Center
AntiAlias=1
Text="SCROLL ME"
MouseScrollUpAction=[!CommandMeasure Scroll "Stop 2"][!CommandMeasure Scroll "Execute 1"]
MouseScrollDownAction=[!CommandMeasure Scroll "Stop 1"][!CommandMeasure Scroll "Execute 2"]
DynamicVariables=1
ScrollingSwitcher_1.2.rmskin
(1.46 KiB) Downloaded 36 times
Last edited by deflore08 on September 21st, 2020, 7:03 am, edited 6 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Trick | Guide] Simple scrolling switcher

Post by balala »

I perfectly understood the reason why did you post this as a tip. However I'd add a little enhancement: a scrolling effect would be nice on your skin. So I rewrote a few things there, here is the new code of Switcher.ini:

Code: Select all

[Metadata]
Name=PlayerSwitcher
Version=1.1
Author=deflore08 (deflore08@gmail.com)
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple switcher example

[Variables]
Player_Name=AIMP
Player_Selection=1
Player_NameUp=WLM
Player_SelectionUp=8
Player_NameDown=CAD
Player_SelectionDown=2
U=[!UpdateMeasure "MeasureScroll"][!UpdateMeasure "MeasureY"][!UpdateMeterGroup "Names"][!Redraw]
Y=0

[Background]
Meter=Image
W=200
H=150
SolidColor=0,0,0,180

; - #Player_Selection# sets player name depending on it's value from 1 to 8. (1=AIMP; 2=CAD; 3=iTunes; 4=MediaMonkey; 5=Winamp; 6=WMP; 7=Spotify; 8=WLM)

[MeasureScroll]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Up,20,10
Up=[!SetVariable Y "(Clamp((#Y#-1),-10,10))"]#U#
ActionList2=Repeat Down,20,10
Down=[!SetVariable Y "(Clamp((#Y#+1),-10,10))"]#U#
DynamicVariables=1

[MeasureY]
Measure=Calc
Formula=#Y#
IfCondition=(#CURRENTSECTION#=-10)
IfTrueAction=[!SetVariable Y "0"][!SetVariable Player_Selection "((#Player_Selection#=1)?8:(#Player_Selection#-1))"][!SetVariable Player_SelectionUp "((#Player_SelectionUp#=1)?8:(#Player_SelectionUp#-1))"][!SetVariable Player_SelectionDown "((#Player_SelectionDown#=1)?8:(#Player_SelectionDown#-1))"][!UpdateMeasure "f.Player_Selection"][!WriteKeyValue Variables Player_Selection "((#Player_Selection#=1)?8:(#Player_Selection#-1))"][!WriteKeyValue Variables Player_SelectionUp "((#Player_SelectionUp#=1)?8:(#Player_SelectionUp#-1))"][!WriteKeyValue Variables Player_SelectionDown "((#Player_SelectionDown#=1)?8:(#Player_SelectionDown#-1))"][!UpdateMeasure "f.Player_Selection"]#U#
IfCondition2=(#CURRENTSECTION#=10)
IfTrueAction2=[!SetVariable Y "0"][!SetVariable Player_Selection "((#Player_Selection#=8)?1:(#Player_Selection#+1))"][!SetVariable Player_SelectionUp "((#Player_SelectionUp#=8)?1:(#Player_SelectionUp#+1))"][!SetVariable Player_SelectionDown "((#Player_SelectionDown#=8)?1:(#Player_SelectionDown#+1))"][!WriteKeyValue Variables Player_Selection "((#Player_Selection#=8)?1:(#Player_Selection#+1))"][!WriteKeyValue Variables Player_SelectionUp "((#Player_SelectionUp#=8)?1:(#Player_SelectionUp#+1))"][!WriteKeyValue Variables Player_SelectionDown "((#Player_SelectionDown#=8)?1:(#Player_SelectionDown#+1))"][!UpdateMeasure "f.Player_Selection"]#U#
DynamicVariables=1

[f.Player_Selection]
Measure=Calc
DynamicVariables=1
IfCondition=#Player_Selection#=1
IfTrueAction=[!SetVariable Player_Name "AIMP"][!SetVariable Player_NameUp "WLM"][!SetVariable Player_NameDown "CAD"][!WriteKeyValue Variables Player_Name "AIMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WLM"][!WriteKeyValue Variables Player_NameDown "CAD"]
IfCondition2=#Player_Selection#=2
IfTrueAction2=[!SetVariable Player_Name "CAD"][!SetVariable Player_NameUp "AIMP"][!SetVariable Player_NameDown "ITUNES"][!WriteKeyValue Variables Player_Name "CAD" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "AIMP"][!WriteKeyValue Variables Player_NameDown "ITUNES"]
IfCondition3=#Player_Selection#=3
IfTrueAction3=[!SetVariable Player_Name "ITUNES"][!SetVariable Player_NameUp "CAD"][!SetVariable Player_NameDown "MEDIAMONKEY"][!WriteKeyValue Variables Player_Name "ITUNES" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "CAD"][!WriteKeyValue Variables Player_NameDown "MEDIAMONKEY"]
IfCondition4=#Player_Selection#=4
IfTrueAction4=[!SetVariable Player_Name "MEDIAMONKEY"][!SetVariable Player_NameUp "ITUNES"][!SetVariable Player_NameDown "WINAMP"][!WriteKeyValue Variables Player_Name "MEDIAMONKEY" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "ITUNES"][!WriteKeyValue Variables Player_NameDown "WINAMP"]
IfCondition5=#Player_Selection#=5
IfTrueAction5=[!SetVariable Player_Name "WINAMP"][!SetVariable Player_NameUp "MEDIAMONKEY"][!SetVariable Player_NameDown "WMP"][!WriteKeyValue Variables Player_Name "WINAMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "MEDIAMONKEY"][!WriteKeyValue Variables Player_NameDown "EMP"]
IfCondition6=#Player_Selection#=6
IfTrueAction6=[!SetVariable Player_Name "WMP"][!SetVariable Player_NameUp "WINAMP"][!SetVariable Player_NameDown "SPOTIFY"][!WriteKeyValue Variables Player_Name "WMP" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WINAMP"][!WriteKeyValue Variables Player_NameDown "SPOTIFY"]
IfCondition7=#Player_Selection#=7
IfTrueAction7=[!SetVariable Player_Name "SPOTIFY"][!SetVariable Player_NameUp "WMP"][!SetVariable Player_NameDown "WLM"][!WriteKeyValue Variables Player_Name "SPOTIFY" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "WMP"][!WriteKeyValue Variables Player_NameDown "WLM"]
IfCondition8=#Player_Selection#=8
IfTrueAction8=[!SetVariable Player_Name "WLM"][!SetVariable Player_NameUp "SPOTIFY"][!SetVariable Player_NameDown "AIMP"][!WriteKeyValue Variables Player_Name "WLM" "Switcher.ini"][!WriteKeyValue Variables Player_NameUp "SPOTIFY"][!WriteKeyValue Variables Player_NameDown "AIMP"]

[t.Scroll_Example]
Meter=String
Y=80
X=0
W=200
H=40
Text="SCROLL ME"
SolidColor=100, 100, 100, 100
FontColor=200, 200, 150, 255
FontSize=24
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
MouseScrollUpAction=[!CommandMeasure "MeasureScroll" "Execute 1"][!CommandMeasure "MeasureScroll" "Stop 2"]
MouseScrollDownAction=[!CommandMeasure "MeasureScroll" "Stop 1"][!CommandMeasure "MeasureScroll" "Execute 2"]

[PlayerNameContainer]
Meter=Image
SolidColor=0,0,0
X=0
Y=20
W=200
H=24
UpdateDivider=-1

[t.Player_NameUp]
Meter=String
Y=(-40+2*(10-#Y#))
X=0
W=200
H=40
Text=#Player_SelectionUp#: #Player_NameUp#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names

[t.Player_Name]
Meter=String
Y=(-20+2*(10-#Y#))
X=0r
W=200
H=40
Text=#Player_Selection#: #Player_Name#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names

[t.Player_NameDown]
Meter=String
Y=(2*(10-#Y#))
X=0r
W=200
H=40
Text=#Player_SelectionDown#: #Player_NameDown#
FontColor=200, 200, 150, 255
FontSize=16
FontFace=ARIAL
StringAlign=Left
AntiAlias=1
DynamicVariables=1
Container=PlayerNameContainer
Group=Names
Result:
GIF.gif
A few things related to both, the original and the rewritten code:
  • I removed the IfCondition / IfTrueAction and IfCondition2 / IfTrueAction2 options of the [f.Player_Selection] measure, because they are not needed. Instead of using these options, I added the [MeasureY] measure, which has bangs into the IfTrueAction and IfTrueAction2 options to do the same.
  • In the MouseScrollUpAction and MouseScrollDownAction options of the [t.Scroll_Example] meter you have between others a [!UpdateMeasure f.Player_Selection] along with a [!Update]. Completely useless to update the [f.Player_Selection] measure if you anyway are updateing the whole skin with [!Update] (I completely rewrote these options).
  • Please don't use unnecessary spaces into the posted codes / uploaded skins. For most users they are confusing, even if the skin is working even so. I think it would be much better to have no unneeded spaces into options.
  • I rewrote the Version number into the [Metadata] section to Version=1.1, since this is a newer version of the same skin.
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City
Contact:

Re: [Trick | Guide] Simple scrolling switcher

Post by deflore08 »

As always, perfectly. :) Yep, there was a useless update things. It was a code part from big skin, looks like i forgot to fix it after experiments, thanks.
Now this scroller looks much better. Interesting, what if make cascade+fade effect. :)) And i believe, your name should be inside as author.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Trick | Guide] Simple scrolling switcher

Post by balala »

deflore08 wrote: September 16th, 2020, 8:09 pm As always, perfectly.
Thank you.
deflore08 wrote: September 16th, 2020, 8:09 pm Yep, there was a useless update things. It was a code part from big skin, looks like i forgot to fix it after experiments, thanks.
Doesn't matter too much, because the skin did anyway work.
deflore08 wrote: September 16th, 2020, 8:09 pm And i believe, your name should be inside as author.
I'm not the author, so there is not needed to add me. But if you want, add my name. It's up to you.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Trick | Guide] Simple scrolling switcher

Post by Yincognito »

This can be further simplified by using just PlayerUp and PlayerDown and switching them in the ActionTimer measure based on the scrolling direction, as well as using a single comma separated string holding all the player names and grabbing the needed two by using regex quantifiers like {N}. Just saying...
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City
Contact:

Re: [Trick | Guide] Simple scrolling switcher

Post by deflore08 »

Yincognito wrote: September 20th, 2020, 8:57 am This can be further simplified by using just PlayerUp and PlayerDown and switching them in the ActionTimer measure based on the scrolling direction, as well as using a single comma separated string holding all the player names and grabbing the needed two by using regex quantifiers like {N}. Just saying...
Hi! :welcome:
Just write it! :lol:
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Trick | Guide] Simple scrolling switcher

Post by Yincognito »

deflore08 wrote: September 20th, 2020, 4:41 pm Hi! :welcome:
Just write it! :lol:
I see what you did there... :lol: Well, I might just will. :sly:
Although, if I think about it, I (partially) already did that, albeit for a different skin... In that skin, although the scrolling is horizontal instead of vertical like in your skin, I use only 2 "names" (it's actually about sets of "names", one for "left" and one for "right"), so to speak, and I also iterated through the values by using "indexes" or "IDs" instead of conditions (see the first !SetVariable bang in the UpdateIn and UpdateOut actions from [MeasureSlideInOut2]). But then, that example is probably too big and complex to be easily understood, so I might just post a variant of your skin, probably based on balala's sugestions.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Trick | Guide] Simple scrolling switcher

Post by Yincognito »

deflore08 wrote: September 20th, 2020, 4:41 pm Hi! :welcome:
Just write it! :lol:
There you go (notice the UpdateUp and UpdateDown actions in [Scroll] and also the substitutes in [PlayerUp] and [PlayerDown]; the former makes using just 2 positions instead of the original 3 possible since they will get switched, and the latter chooses the N-th player from the player list string):

Code: Select all

[Variables]
Players="AIMP,CAD,iTunes,MediaMonkey,Winamp,WMP,Spotify,WLM"
PlayerCount=8
PlayerUpIndex=0
PlayerUp=AIMP
U=[!UpdateMeasure "Scroll"][!UpdateMeter *][!Redraw]
Y=0

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=PlayerSwitcher
Version=1.1
Author=balala (http://balazslaci.deviantart.com/) | deflore08 (deflore08@gmail.com)
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple switcher example

---Measures---

[Scroll]
Group=ScrollGroup
Measure=Plugin
Plugin=ActionTimer
ActionList1=UpdateUp | Wait 5 | Repeat Up,15,24 | Wait 5
Up=[!SetVariable Y (Clamp((#Y#+1),-24,0))]#U#
UpdateUp=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#-1)%#PlayerCount#)][!SetVariable Y -24][!UpdateMeasureGroup "ScrollGroup"]#U#
ActionList2=Repeat Down,15,24 | Wait 5 | UpdateDown | Wait 5
Down=[!SetVariable Y (Clamp((#Y#-1),-24,0))]#U#
UpdateDown=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)][!SetVariable Y 0][!UpdateMeasureGroup "ScrollGroup"]#U#
DynamicVariables=1

[PlayerUpIndex]
Group=ScrollGroup
Measure=Calc
Formula=(#PlayerUpIndex#)
UpdateDivider=-1
OnUpdateAction=[!WriteKeyValue Variables PlayerUpIndex [PlayerUpIndex]]
DynamicVariables=1

[PlayerUp]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerUpIndex]}(.*),.*$":"\1"
OnUpdateAction=[!WriteKeyValue Variables PlayerUp "[PlayerUp]"]
DynamicVariables=1

[PlayerDownIndex]
Group=ScrollGroup
Measure=Calc
Formula=((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)
UpdateDivider=-1
DynamicVariables=1

[PlayerDown]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerDownIndex]}(.*),.*$":"\1"
DynamicVariables=1

---Meters---

[Background]
Meter=Image
W=200
H=150
SolidColor=0,0,0,180

[Container]
Meter=Image
SolidColor=0,0,0,255
X=0
Y=20
W=200
H=24

[PlayerUpName]
Container=Container
Group=NamesGroup
Meter=String
X=10
Y=(#Y#)
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerUpIndex
MeasureName2=PlayerUp
Text="%1: %2"
DynamicVariables=1

[PlayerDownName]
Container=Container
Group=NamesGroup
Meter=String
X=0r
Y=0R
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerDownIndex
MeasureName2=PlayerDown
Text="%1: %2"
DynamicVariables=1

[ScrollText]
Meter=String
X=100
Y=80
W=200
H=40
SolidColor=100,100,100,100
FontColor=200,200,150,255
FontSize=24
FontFace=Arial
StringAlign=Center
AntiAlias=1
Text="SCROLL ME"
MouseScrollUpAction=[!CommandMeasure Scroll "Stop 2"][!CommandMeasure Scroll "Execute 1"]
MouseScrollDownAction=[!CommandMeasure Scroll "Stop 1"][!CommandMeasure Scroll "Execute 2"]
DynamicVariables=1
I kind of butchered your little skin a bit formatting things the way I like, but it's the result and the approach that matters, after all. :D
You don't necessarily need to add me to the credits or use my code, this is mainly posted so that what I said earlier would have a practical representation. Feel free to do as you wish with it. ;-)
User avatar
deflore08
Posts: 209
Joined: July 12th, 2020, 7:47 am
Location: Ada, Garden City
Contact:

Re: [Trick | Guide] Simple scrolling switcher

Post by deflore08 »

Yincognito wrote: September 20th, 2020, 10:04 pm There you go (notice the UpdateUp and UpdateDown actions in [Scroll] and also the substitutes in [PlayerUp] and [PlayerDown]; the former makes using just 2 positions instead of the original 3 possible since they will get switched, and the latter chooses the N-th player from the player list string):

Code: Select all

[Variables]
Players="AIMP,CAD,iTunes,MediaMonkey,Winamp,WMP,Spotify,WLM"
PlayerCount=8
PlayerUpIndex=0
PlayerUp=AIMP
U=[!UpdateMeasure "Scroll"][!UpdateMeter *][!Redraw]
Y=0

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=PlayerSwitcher
Version=1.1
Author=balala (http://balazslaci.deviantart.com/) | deflore08 (deflore08@gmail.com)
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Information=Simple switcher example

---Measures---

[Scroll]
Group=ScrollGroup
Measure=Plugin
Plugin=ActionTimer
ActionList1=UpdateUp | Wait 5 | Repeat Up,15,24 | Wait 5
Up=[!SetVariable Y (Clamp((#Y#+1),-24,0))]#U#
UpdateUp=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#-1)%#PlayerCount#)][!SetVariable Y -24][!UpdateMeasureGroup "ScrollGroup"]#U#
ActionList2=Repeat Down,15,24 | Wait 5 | UpdateDown | Wait 5
Down=[!SetVariable Y (Clamp((#Y#-1),-24,0))]#U#
UpdateDown=[!SetVariable PlayerUpIndex ((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)][!SetVariable Y 0][!UpdateMeasureGroup "ScrollGroup"]#U#
DynamicVariables=1

[PlayerUpIndex]
Group=ScrollGroup
Measure=Calc
Formula=(#PlayerUpIndex#)
UpdateDivider=-1
OnUpdateAction=[!WriteKeyValue Variables PlayerUpIndex [PlayerUpIndex]]
DynamicVariables=1

[PlayerUp]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerUpIndex]}(.*),.*$":"\1"
OnUpdateAction=[!WriteKeyValue Variables PlayerUp "[PlayerUp]"]
DynamicVariables=1

[PlayerDownIndex]
Group=ScrollGroup
Measure=Calc
Formula=((#PlayerCount#+#PlayerUpIndex#+1)%#PlayerCount#)
UpdateDivider=-1
DynamicVariables=1

[PlayerDown]
Group=ScrollGroup
Measure=String
String="#Players#,"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?U)^(?:.*,){[PlayerDownIndex]}(.*),.*$":"\1"
DynamicVariables=1

---Meters---

[Background]
Meter=Image
W=200
H=150
SolidColor=0,0,0,180

[Container]
Meter=Image
SolidColor=0,0,0,255
X=0
Y=20
W=200
H=24

[PlayerUpName]
Container=Container
Group=NamesGroup
Meter=String
X=10
Y=(#Y#)
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerUpIndex
MeasureName2=PlayerUp
Text="%1: %2"
DynamicVariables=1

[PlayerDownName]
Container=Container
Group=NamesGroup
Meter=String
X=0r
Y=0R
W=190
H=24
FontColor=200,200,150,255
FontSize=16
FontFace=Arial
StringAlign=Left
AntiAlias=1
MeasureName=PlayerDownIndex
MeasureName2=PlayerDown
Text="%1: %2"
DynamicVariables=1

[ScrollText]
Meter=String
X=100
Y=80
W=200
H=40
SolidColor=100,100,100,100
FontColor=200,200,150,255
FontSize=24
FontFace=Arial
StringAlign=Center
AntiAlias=1
Text="SCROLL ME"
MouseScrollUpAction=[!CommandMeasure Scroll "Stop 2"][!CommandMeasure Scroll "Execute 1"]
MouseScrollDownAction=[!CommandMeasure Scroll "Stop 1"][!CommandMeasure Scroll "Execute 2"]
DynamicVariables=1
I kind of butchered your little skin a bit formatting things the way I like, but it's the result and the approach that matters, after all. :D
You don't necessarily need to add me to the credits or use my code, this is mainly posted so that what I said earlier would have a practical representation. Feel free to do as you wish with it. ;-)
Oh, great.. Thanks! By the way, this method are protected and prevent a bugs with scrolling that i've got sometimes when AuroraBar is on. Which bugs?.. I am not sure you want to know. :rolmfao:
Well folks.. It became a like rosetta-code task now. So what about lua-solution for this? :lol:
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Trick | Guide] Simple scrolling switcher

Post by Yincognito »

deflore08 wrote: September 21st, 2020, 6:51 am Oh, great.. Thanks! By the way, this method are protected and prevent a bugs with scrolling that i've got sometimes when AuroraBar is on. Which bugs?.. I am not sure you want to know. :rolmfao:
Well folks.. It became a like rosetta-code task now. So what about lua-solution for this? :lol:
Yeah, too bad numerical variables aren't resolved when using !SetVariable unless you also create Calc measures for them, cause it would have saved me from adding the somewhat redundant [PlayerUpIndex] and [PlayerDownIndex] measures to the code.

Maybe a Lua version would solve another dozen of bugs in AuroraBar, so push hard for it... :sly:
Post Reply