It is currently April 25th, 2024, 7:25 am

Add a Volume Slider with popping up

Get help with creating, editing & fixing problems with skins
Franzishans123
Posts: 8
Joined: January 7th, 2023, 8:55 pm

Add a Volume Slider with popping up

Post by Franzishans123 »

Hello, as you can see I need some help. I want to add a Slider to control the Volume. I have already a code where I got a Symbol which changes by different Volumes. Now i want a slider which pops up if i click on the symbols. On the slider I want to change the volume by dragging and maybe clicking. The slider should disappear after a specific time. Please give me some help :D

Here is the code

Code: Select all

[Rainmeter]
Update=20


[Variables]

VolumeBarColor=255,255,255 		


[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin


IfConditionMode=1
IfCondition=(MeasureVolume <= 0)
IfTrueAction=[!SetOption Icon imagename #SKINSPATH#VolumeBar\Volume\Volume0.png]
IfCondition2=(MeasureVolume <= 33) && (MeasureVolume >= 1)
IfTrueAction2=[!SetOption Icon imagename #SKINSPATH#VolumeBar\Volume\Volume1.png]
IfCondition3=(MeasureVolume <= 66) && (MeasureVolume >= 34)
IfTrueAction3=[!SetOption Icon imagename #SKINSPATH#VolumeBar\Volume\Volume2.png]
IfCondition4=(MeasureVolume <= 100) && (MeasureVolume >= 67)
IfTrueAction4=[!SetOption Icon imagename #SKINSPATH#VolumeBar\Volume\Volume3.png]

[MeasurePercent]
Measure=CALC
Formula=MeasureVolume
Substitute="-1":"0"
IfAboveValue=-1
IfAboveAction=!SetOption VolumeText Postfix "%"

[Icon]
meter=image
imagetint=255,255,255
y=30
H=40
PreserveAspectRatio=1
AntiAlias=1
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure "MeasureVolume" "ToggleMute"][!Update]
Last edited by eclectic-tech on March 22nd, 2023, 5:03 pm, edited 1 time in total.
Reason: Please use the code tag </> when posting long codes.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Add a Volume Slider with popping up

Post by balala »

Franzishans123 wrote: March 22nd, 2023, 4:39 pm I want to add a Slider to control the Volume. I have already a code where I got a Symbol which changes by different Volumes. Now i want a slider which pops up if i click on the symbols. On the slider I want to change the volume by dragging and maybe clicking. The slider should disappear after a specific time.
For first let's try to create the slider and don't hide it after the "specific time". The disappearance is definitely not something hard to be done, not this is the problem, so in the attached skin the slider is always visible. Please download and install the attached package. Note that you have to install it, because besides the VolumeSlider config, it installs a plugin as well, called Mouse, which has been created by NighthawkSLO. It is needed to can realize dragging. Without this plugin (or obviously out there might be others as well, however one is needed anyway), setting the volum by simple click might be possible, however dragging is completely impossible (or at least extremely hard to be achieved). The package installs the appropriate version of the plugin as well.
When the installation is finished, the skin loads. It is based on your code, but I added lot of things (a VolLev variable and sections like [MeasureSetVol], [MeasureMouseVolLev], [MeterSliderLineVolLevBackground], [MeterSliderLineVolLev] and [MeterSlider]). The dragging operation is done through the LeftMouseDragAction option of the [MeasureMouseVolLev] newlly added measure.
I replaced the original Update=20 option of the [Rainmeter] section by the default Update=1000. I don't see anything in the posted code which would require such a low Update. I also removed the IfConditionMode=1 option from the [MeasureVolume] measure, because there is need to execute one of the IfTrueAction options of the measure once per update (so once per 20 milliseconds with the original Update, not even once per second with the altered Update).
The skin definitely needs to be improved (as said, for instance the disappearance of the slider is not realized so far). But for first, I'd like you to give it a try and let me know what you think about it. Then we'll see...
You do not have the required permissions to view the files attached to this post.
Franzishans123
Posts: 8
Joined: January 7th, 2023, 8:55 pm

Re: Add a Volume Slider with popping up

Post by Franzishans123 »

Thank you very much for your help. I am still trying to search a way to implement a command when i doubleclick on the volume icon to pop up the slider and implement a "fade" option for it.

But as your descreiption says that your a Rainmetersage, I'd like to ask you another question.

Here I have a Bluetooth Code, which i found on a forum. The only thing I want to change is that when I click on the Icon (so that Bluetooth switches off) I want that the Icon image switches to another image instead of changing the color (which was the original code, i already changed that color to white)

Maybe you have an idea to implement a little

Code: Select all

[Rainmeter]
Update=1000

;DefaultUpdateDivider=-1
Group=AllNoWeather | Utilities2 | Settings | AllNoVisualizer
;BackgroundMode=3
;DynamicWindowsize=1
AccurateText=1
;OnRefreshAction=#BT_CheckBluetooth#
ContextTitle="#BluetoothSettings#..."
ContextAction=[!ActivateConfig "#ROOTCONFIG#\Settings" "System-Utilities-Settings.ini"]
ContextTitle2="#ConnectDevice#..."
ContextAction2=#BluetoothDeviceWindow#
MiddleMouseUpAction=[!CommandMeasure "MeasureAudioDevice" "ToggleNext"][!Delay 1200][!SetVariable LoadingRadians "0"][!Delay 16][!UpdateMeasureGroup Animate][!UpdateMeter MeterRoundline][!Update][!Redraw]
;[!CommandMeasure Animation "Execute 1"]

[Metadata]
Author=mpurses, BT plugin by SweetMNM
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=22.1.0
Information=Bluetooth Controls, Turn on (and open connection window) and off, right-click to change audio device, Middle-Click to Toggle to next audio source.

[Variables]
@include2=#@#Variables.inc
@IncludeLanguage=#@#Language\Skin\#Language#.inc
@include3=#@#Bluetooth\bluetoothVariables.inc

VolumeBGMarginScaled=(#UtilitiesScale#*#VolumeBGMargin#)
ContainerH=(#UtilitiesScale#*#VolumeBarWidth#)
ContainerW=(#UtilitiesScale#*#VolumeBarWidth#)
VolumeIconSizeScaled=(#UtilitiesScale#*#VolumeIconSize#)
;U=[!UpdateMeasure Slider][!UpdateMeter *][!Redraw]
LoadingRadians=0
LoadingRadiansMax=6.283
AnimDivider=6

sBTState=-1
BluetoothIconBGColorCurrent=#BluetoothIconBGColorOff#
BT_OnBluetoothCheck_On=[!SetVariable sBTState 1][!SetVariable BluetoothIconBGColorCurrent #BluetoothIconBGColorOn#][!SetOption MeterBluetoothImage Imagetint #BluetoothIconColorOn#][!UpdateMeter MeterBackContainer2][!UpdateMeter MeterBluetoothImage][!Redraw]
BT_OnBluetoothCheck_Off=[!SetVariable sBTState 0][!SetVariable BluetoothIconBGColorCurrent #BluetoothIconBGColorOff#][!SetOption Icon imagename #SKINSPATH#Sonder\System\Bluetooth\bluetooth.png][!Redraw]
OnSwitchHandlerDisabled=[]
OnSwitchHandlerOn=#BT_TurnOffBluetooth#[!SetVariable SwitchValidate 0][!SetVariable sBTState 0]
BT_AfterBluetoothTurnedOff=[!SetVariable SwitchValidate 1][!SetOption Icon imagename #SKINSPATH#Sonder\System\Bluetooth\bluetooth.png][!Redraw][!Refresh]
OnSwitchHandlerOff=#BT_TurnOnBluetooth# [!SetOption Icon imagename #SKINSPATH#Sonder\System\Bluetooth\bluetooth.png]
BT_AfterBluetoothTurnedOn=[!SetVariable SwitchValidate 1][!UpdateMeter MeterBackContainer2][!UpdateMeter MeterBluetoothImage][!Redraw][!Refresh]
SwitchValidate=1
TriggerSwitch=[!EnableMeasure MeasureSwitchValidate][!UpdateMeasure MeasureSwitchValidate][!Redraw]

@include5=#@#Bluetooth\bluetooth.inc

ShowTitle=[!CommandMeasure LuaTweener "Start(0)"][!Delay 500][!CommandMeasure LuaTweener "Start(1)"]
HideTitle=[!CommandMeasure LuaTweener "Reverse(1)"][!Delay 500][!CommandMeasure LuaTweener "Reverse(0)"]
DoStartBang=#ShowTitle#
DoHideBang=#HideTitle#

;================================== Bluetooth MEASURES ============================================
[MeasureAudioDevice]
Measure=Plugin
Plugin=Win7AudioPlugin
;Substitute="Speakers / Headphones":"1"
; IfCondition=(#CURRENTSECTION#=0)
; IfTrueAction=[!HideMeter "MeterHeadset"][!ShowMeter "MeterSpeakers"][!Redraw]
; IfFalseAction=[!ShowMeter "MeterHeadset"][!HideMeter "MeterSpeakers"][!Redraw]

[MeasureBluetoothChanges]
Measure=Calc
Formula=#sBTState#
;Check every few seconds for changes, can't check at default rate as program takes more than a sec to detect.
UpdateDivider=4
DynamicVariables=1
OnUpdateAction=#BT_CheckBluetooth#
;Substitute="1":"#BluetoothIconBGColorOn#","0":"#BluetoothIconBGColorOn#"

[MeasureSwitchValidate]
Measure=Calc
UpdateDivider=-1
Disabled=1
Formula=#SwitchValidate#
DynamicVariables=1
IfCondition=MeasureSwitchValidate = 0
IfTrueAction=#OnSwitchHandlerDisabled#
IfCondition2=(MeasureSwitchValidate = 1) && (#sBTState# = 1)
IfTrueAction2=#OnSwitchHandlerOn#
IfCondition3=(MeasureSwitchValidate = 1) && (#sBTState# = 0)
IfTrueAction3=#OnSwitchHandlerOff#
IfConditionMode=1



;MAIN BLUETOOTH ICON BACKGROUND
[MeterBackContainer2]
Meter=Shape
X=(#ContainerW#/2+#VolumeBGMarginScaled#)
Y=(#ContainerW#/2+#VolumeBGMarginScaled#)
Shape=Ellipse 0,0,(#ContainerW#/2),(#ContainerW#/2) | Fill Color #BluetoothIconBGColorCurrent# | StrokeWidth 3 | Stroke Color 0,0,0,0
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure Animation "Execute 1"]#TriggerSwitch#[!Delay 200][!SetVariable LoadingRadians "0"][!Delay 16][!UpdateMeasureGroup Animate][!UpdateMeter MeterRoundline][!Update][!Redraw]

;BLUETOOTH ICON
[MeterBluetoothImage]
Meter=Image
ImageName=#@#Images\Bluetooth.png
X=((#ContainerW#/2)+#VolumeBGMarginScaled#-(#VolumeIconSizeScaled#/2))
Y=((#ContainerW#/2)+#VolumeBGMarginScaled#-(#VolumeIconSizeScaled#/2))
W=#VolumeIconSizeScaled#
H=#VolumeIconSizeScaled#
Imagetint=#BluetoothIconColorCurrent#

[MeterRoundline]
Meter=Roundline
Group=Animate
Solid=1
X=(#ContainerW#/2+#VolumeBGMarginScaled#)
Y=(#ContainerW#/2+#VolumeBGMarginScaled#)
LineLength=(#ContainerW#/2)
LineColor=#BluetoothIconBGColorOn2#
LineStart=(#ContainerW#/2-3)
StartAngle=(-1.57)
RotationAngle=#LoadingRadians#
AntiAlias=1
DynamicVariables=1

;BG Hover Image
[Background]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=(#ContainerW#+#VolumeBGMarginScaled#*2)
H=(#ContainerH#+#VolumeBGMarginScaled#*2)
;DynamicVariables=1
Last edited by balala on March 28th, 2023, 5:26 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting codes. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Add a Volume Slider with popping up

Post by balala »

Franzishans123 wrote: March 28th, 2023, 5:15 pm Here I have a Bluetooth Code, which i found on a forum. The only thing I want to change is that when I click on the Icon (so that Bluetooth switches off) I want that the Icon image switches to another image instead of changing the color (which was the original code, i already changed that color to white)

Maybe you have an idea to implement a little
No, I don't have and no one have. We don't have because we can't try out the posted code. It can't be used because it includes plenty of unknown things, like variables (for instance BluetoothSettings, ConnectDevice, UtilitiesScale, VolumeBGMargin, VolumeBarWidth, VolumeIconSize and so on), files (like @Resources\Variables.inc or @Resources\Bluetooth\bluetoothVariables.inc). As a result when I try to load the skin, nothing is appearing on the screen, the skin remians empty. but not so the log, where thousands of error messages are shown.
So in order to can try out the code and can give a better answer, pack please the whole config you have (the folder in the Skins folder, where the skins .ini file resides) and upload the package. Hopefully having that package we'll be able to help you further.
Franzishans123
Posts: 8
Joined: January 7th, 2023, 8:55 pm

Re: Add a Volume Slider with popping up

Post by Franzishans123 »

Ah, yeah sure. Here is the link to the creator. The Bluetooth Skin I am looking for is under \System\Bluetooth


https://www.deviantart.com/michaelpurses/art/Sonder-Rainmeter-skin-838147223
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Add a Volume Slider with popping up

Post by balala »

Franzishans123 wrote: March 28th, 2023, 9:22 pm Ah, yeah sure. Here is the link to the creator. The Bluetooth Skin I am looking for is under \System\Bluetooth
Add the following options to the [MeasureBluetoothChanges] measure, without altering the other existing options of the measure:

Code: Select all

[MeasureBluetoothChanges]
...
;UpdateDivider=4
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterBluetoothImage ImageName "#@#Images\brightness.png"][!UpdateMeter "MeterBluetoothImage"][!Redraw]
IfFalseAction=[!SetOption MeterBluetoothImage ImageName "#@#Images\bluetooth.png"][!UpdateMeter "MeterBluetoothImage"][!Redraw]
...
Note that I used the @Resources\Images\bluetooth.png image to be shown when bluetooth is on, respectively @Resources\Images\brightness.png when bluetooth is off. You should replace these images with the desired ones for both cases.
I also removed the UpdateDivider=4 option of the above [MeasureBluetoothChanges] measure, to get the image changing quicker when you turn bluetooth on or off. This is why I posted it into the above code, as being commented out.
Please check the above solution and let me know if it does work as expected.
Franzishans123
Posts: 8
Joined: January 7th, 2023, 8:55 pm

Re: Add a Volume Slider with popping up

Post by Franzishans123 »

Thank you very much. It works perfect.

I attached an image of current work, literally a interface change of windows, so I can operate it easier on a tablet mounted on a tractor.

May i ask you why on some Icon only the white lines are clickable? These are selfmade Icons btw.
Icons on image 1 are clickable only on the white lines.
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Add a Volume Slider with popping up

Post by eclectic-tech »

Add SolidColor=0,0,0,1 to each icon meter to make the entire icon area clickable. See: General Meter Options
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Add a Volume Slider with popping up

Post by balala »

eclectic-tech probably fixed the clicking issue, however I have another question, because I'm not sure I follow you.
Franzishans123 wrote: April 2nd, 2023, 10:15 am so I can operate it easier on a tablet mounted on a tractor.
"tablet mounted on a tractor"? What do you mean by this? These days there are extremely few tablets running Windows as OS. But Rainmeter doesn't work neither on Android, nor on iOS. And what about the tractor?
Franzishans123
Posts: 8
Joined: January 7th, 2023, 8:55 pm

Re: Add a Volume Slider with popping up

Post by Franzishans123 »

balala wrote: April 2nd, 2023, 7:04 pm eclectic-tech probably fixed the clicking issue, however I have another question, because I'm not sure I follow you.

"tablet mounted on a tractor"? What do you mean by this? These days there are extremely few tablets running Windows as OS. But Rainmeter doesn't work neither on Android, nor on iOS. And what about the tractor?

The farming vehicle, a tractor. Using a software for autosteering and Windows is not really optimized for Tablet Users, so I try to install some Rainmeter skins to make the controlling of the tablet more like a tablet OS. Got a Ms Surface pro, which is Tablet running Windows.