Page 1 of 7
Mouse plugin from NighthawkSLO
Posted: May 19th, 2017, 3:47 am
by jsmorley
This skin will demonstrate using the Mouse plugin created by NighthawkSLO to create a "slider", in this case used to control the system volume.
The plugin can be downloaded at:
https://github.com/NighthawkSLO/Mouse.dll/releases
Documentation for the plugin can be found at:
https://github.com/NighthawkSLO/Mouse.dll/wiki/Documentation
MouseVolume_1.0.rmskin
You can drag the slider or use the mouse wheel to change the volume. Click the icon to toggle mute.
gif.gif
Code: Select all
[Rainmeter]
Update=500
DynamicWindowSize=1
AccurateText=1
[Metadata]
Name=MouseVolume
Author=JSMorley
Information=Demonstrates using the Mouse plugin from NighthawkSLO to create a "slider" | Documentation for the plugin is at https://github.com/NighthawkSLO/Mouse.dll/wiki/Documentation
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=May 18, 2017
[Variables]
VolumeIncrement=1
[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin
IfCondition=MeasureWin7Audio = -1
IfTrueAction=[!SetOption MeterMuteIcon ImageName "volume_mute.png"]
IfFalseAction=[!SetOption MeterSlider X "(([MeasureWin7Audio:] * (200 - 20) / 100) + 20)"][!UpdateMeter *][!Redraw]
IfCondition2=(MeasureWin7Audio = 0)
IfTrueAction2=[!SetOption MeterMuteIcon ImageName "volume_0.png"]
IfCondition3=(MeasureWin7Audio > 0) && (MeasureWin7Audio <= 34)
IfTrueAction3=[!SetOption MeterMuteIcon ImageName "volume_1.png"]
IfCondition4=(MeasureWin7Audio > 34) && (MeasureWin7Audio <= 67)
IfTrueAction4=[!SetOption MeterMuteIcon ImageName "volume_2.png"]
IfCondition5=(MeasureWin7Audio > 67)
IfTrueAction5=[!SetOption MeterMuteIcon ImageName "volume_3.png"]
IfConditionMode=1
; MeasureMouse is the meat and potatoes of creating a slider. MeasurePercent is used to turn the position into a percentage for use various places.
[MeasureMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetOption MeterSlider X "(Clamp($MouseX$,20,200))"][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!CommandMeasure MeasureMouse "Stop"]
RelativeToSkin=1
RequireDragging=1
DynamicVariables=1
[MeasurePercent]
Measure=Calc
Formula=[MeterSlider:X]
MinValue=20
MaxValue=200
DynamicVariables=1
IfCondition=MeasureWin7Audio > -1
IfTrueAction=[!CommandMeasure "MeasureWin7Audio" "SetVolume [MeasurePercent:%,0]"]
IfConditionMode=1
[MeterSkinBack]
Meter=Shape
Shape=Rectangle 0.5,0.5,238,75,12 | Fill Color 0,0,0,255 | StrokeWidth 1.5 | Stroke Color 150,150,150,255
W=251
H=76
MouseActionCursor=0
MouseScrollDownAction=[!CommandMeasure MeasureWin7Audio "ChangeVolume -#VolumeIncrement#"][!Update]
MouseScrollUpAction=[!CommandMeasure MeasureWin7Audio "ChangeVolume +#VolumeIncrement#"][!Update]
UpdateDivider=-1
[MeterSlideBack]
Meter=Shape
X=20
Y=20
Shape=Rectangle 0,0,200,10,5 | Fill Color 150,150,150,255 | StrokeWidth 0
[MeterSlideBar]
Meter=Shape
X=20
Y=20
Shape=Rectangle 0,0,[MeterSlider:X],10,5 | Fill Color 56,150,51,255 | StrokeWidth 0
DynamicVariables=1
[MeterSlider]
Meter=Shape
Y=15
Shape=Ellipse 10,10,10,10 | Fill Color 106,222,100,255 | StrokeWidth 0
LeftMouseDownAction=[!CommandMeasure MeasureMouse "Start"]
[MeterPercent]
Meter=String
X=22
Y=45
FontSize=11
FontWeight=700
FontColor=255,255,255,255
Percentual=1
NumOfDecimals=0
AntiAlias=1
DynamicVariables=1
Text=Volume: [MeasurePercent:%,0]%
[MeterMuteIcon]
Meter=Image
X=193
Y=41
W=20
PreserveAspectRatio=1
ImagePath=#@#
LeftMouseUpAction=[!CommandMeasure "MeasureWin7Audio" "ToggleMute"]
Re: Demonstrating the Mouse plugin
Posted: May 19th, 2017, 8:53 am
by balala
I don't contest a such plugin would be helpful in many cases, however a slider can be created even without any plugin.
Re: Demonstrating the Mouse plugin
Posted: May 19th, 2017, 9:01 am
by khanhas
Glad Nighthawk officially released Mouse.dll. This plugin has endless possibilities and is really fun to play around.
I don't know should I open another thread so I just post it here and hope communities find this plugin interesting and start making more interactive skins.
Here another volume changer but this time it's round.
Code: Select all
[Rainmeter]
Update=16
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!Draggable 0]
[Variables]
MousePositionX=-1
MousePositionY=-1
[Radius]
Measure=Calc
Formula=100
[CenterX]
Measure=Calc
Formula=200
[CenterY]
Measure=Calc
Formula=200
[DragPositionX]
Measure=Calc
Formula=CenterX + Radius * cos(PI/2 - (Percent/100) * 2 * PI)
[DragPositionY]
Measure=Calc
Formula=CenterY - Radius * sin(PI/2 - (Percent/100) * 2 * PI)
[Shape]
Meter=Shape
DynamicVariables=1
;Rectangle base
Shape = Rectangle 50,50,300,300,10 | StrokeWidth 0
;Circle base
Shape2= Ellipse [CenterX],[CenterY],[Radius] | StrokeWidth 5 | Fill Color 0,0,0,1 | StrokeColor 255,100,0,150
; { Drag Point } { Statis Point }
Shape3= Arc [DragPositionX],[DragPositionY], ([CenterX]+1),([CenterY]-[Radius]), [Radius],[Radius], 0,1, (round([Percent]/100)),0 | StrokeWidth 7 | Stroke Color 255,100,0 | StrokeStartCap Round | StrokeEndCap Round
;A Knob for decoration
Shape4= Ellipse [DragPositionX],[DragPositionY],10 |Fill Color 255,100,0 | StrokeWidth 0
[Percent]
Measure=Calc
Formula=MouseCalc * 100
OnChangeAction=[!CommandMeasure MeasureVolume "SetVolume [Percent]"]
DynamicVariables=1
[MeasureVolume]
Measure=Plugin
Plugin=Win7AudioPlugin
[MouseCalc]
Measure=Calc
Formula=((#MousePositionY# <> -1) && (#MousePositionY# <> -1)) ? ((Atan2(CenterX-#MousePositionX#, #MousePositionY#-CenterY) + PI)/(2*PI)) : ([MeasureVolume:]/100)
DynamicVariables=1
[MeasureMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseUpAction=[!SetVariable MousePositionX -1][!SetVariable MousePositionY -1]
LeftMouseDragAction=[!SetVariable MousePositionX $MouseX$][!SetVariable MousePositionY $MouseY$]
[String]
Meter=String
Text=[Percent:0]%
AntiAlias=1
DynamicVariables=1
FontFace=Segoe UI
FontSize=20
FontColor=88888888
StringAlign=CenterCenter
X=[CenterX]
Y=[CenterY]
Re: Demonstrating the Mouse plugin
Posted: July 3rd, 2017, 8:02 pm
by StArL0rd84
Figured it could also be used to resize a skin
Yet another use of this awesome plugin!
Click GIF to see it in action.
ezgif.com-video-to-gif.gif
Looks real smooth irl
Code: Select all
[RainMeter]
Update=1000
AccurateText=1
OnRefreshAction=[!SetTransparency "#SkinTrans#"][!SetVariable CurrMon [mCurrMon]][!WriteKeyValue Variables CurrMon "[mCurrMon]" "#NasaVar#"][!UpdateMeterGroup Sizable][!UpdateMeter *][!Redraw]
MouseOverAction=[!ShowMeterGroup Nav][!ShowMeterGroup Resize][!ShowMeterGroup Title][!UpdateMeter *][!Redraw][!ZPos "#MoPos#"]
MouseLeaveAction=[!HideMeterGroup Nav][!HideMeterGroup Resize][!HideMeterGroup Title][!UpdateMeter *][!Redraw][!ZPos "#MlPos#"]
[Variables]
@include=#@#Variables\Variables.inc
@include1=#@#Variables\NasaVars.inc
@include2=#@#Variables\ThemesVars.inc
@include3=#@#Variables\Themes\#SelectedTheme#.inc
DragPointX=564
DragPointY=428
CurrMon=1
CurrMonHeight=1440
CurrMonWidth=3440
[TextStyle]
Meter=String
FontColor=#TextColor2#
FontSize=10
FontFace=ITC Avant Garde Pro Bk
StringStyle=Normal
StringAlign=Center
ClipString=2
AntiAlias=1
DynamicVariables=1
[Top1]
Meter=Image
ImageName=#@#Images\Backgrounds\Top.png
ImageTint=#AccentColor#
AntiAlias=1
[Top2]
Meter=Image
ImageName=#@#Images\Backgrounds\Top.png
ImageTint=#AccentColor#
AntiAlias=1
X=([mMouseX]-296)
DynamicVariables=1
Group=Sizable
[TopMiddle]
Meter=Image
SolidColor=#AccentColor#
AntiAlias=1
X=(([mMouseX]/2)-([TopMiddle:W]/2))+2
W=([Card:W])-16
H=4
DynamicVariables=1
Group=Sizable
[Card]
Meter=Image
Y=4
W=([mMouseX]+4)
H=([mMouseY]-4)
SolidColor=#CardColor#
DynamicVariables=1
Group=Sizable
[Bottom]
Meter=Image
ImageName=#@#Images\Backgrounds\Top.png
ImageTint=#AccentColor#
ImageFlip=Vertical
Y=[mMouseY]
AntiAlias=1
DynamicVariables=1
[Bottom2]
Meter=Image
ImageName=#@#Images\Backgrounds\Top.png
ImageTint=#AccentColor#
ImageFlip=Vertical
AntiAlias=1
X=([mMouseX]-296)
Y=r
DynamicVariables=1
Group=Sizable
[BottomMiddle]
Meter=Image
SolidColor=#AccentColor#
AntiAlias=1
X=(([mMouseX]/2)-([BottomMiddle:W]/2))+2
Y=r
W=([Card:W])-16
H=4
DynamicVariables=1
Group=Sizable
[mMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetOption mMouseX Formula "clamp($MouseX$,296,#CurrMonWidth#)"][!UpdateMeasure mMouseX][!SetOption mMouseY Formula "clamp($MouseY$,46,#CurrMonHeight#)"][!UpdateMeasure mMouseY][!UpdateMeterGroup Sizable][!ShowMeterGroup Nav][!ShowMeterGroup Resize][!ShowMeterGroup Title][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!CommandMeasure mMouse "Stop"]
RequireDragging=1
DynamicVariables=1
[mMouseX]
Measure=Calc
Formula=#DragPointX#
DynamicVariables=1
OnChangeAction=[!SetVariable DragPointX [mMouseX]][!WriteKeyValue Variables DragPointX "[mMouseX]" "#NasaVar#"]
[mMouseY]
Measure=Calc
Formula=#DragPointY#
DynamicVariables=1
OnChangeAction=[!SetVariable DragPointY [mMouseY]][!WriteKeyValue Variables DragPointY "[mMouseY]" "#NasaVar#"]
[mNumMon]
Measure=Plugin
Plugin=SysInfo
SysInfoType=NUM_MONITORS
[mCurrMon]
Measure=Script
ScriptFile=#@#lua\CurrentMonitor.lua
NumMonitors=[mNumMon]
OnChangeAction=[!SetVariable CurrMon [mCurrMon]][!WriteKeyValue Variables CurrMon "[mCurrMon]" "#NasaVar#"]
IfCondition=(mCurrMon=1)
IfTrueAction=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@1#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@1#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@1#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@1#" "#NasaVar#"]
IfCondition2=(mCurrMon=2)
IfTrueAction2=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@2#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@2#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@2#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@2#" "#NasaVar#"]
IfCondition3=(mCurrMon=3)
IfTrueAction3=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@3#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@3#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@3#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@3#" "#NasaVar#"]
IfCondition4=(mCurrMon=4)
IfTrueAction4=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@4#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@4#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@4#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@4#" "#NasaVar#"]
IfCondition5=(mCurrMon=5)
IfTrueAction5=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@5#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@5#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@5#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@5#" "#NasaVar#"]
IfCondition6=(mCurrMon=6)
IfTrueAction6=[!SetVariable CurrMonWidth #SCREENAREAWIDTH@6#][!WriteKeyValue Variables CurrMonWidth "#SCREENAREAWIDTH@6#" "#NasaVar#"][!SetVariable CurrMonHeight #SCREENAREAHEIGHT@6#][!WriteKeyValue Variables CurrMonHeight "#SCREENAREAHEIGHT@6#" "#NasaVar#"]
[mSDO]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#SDOURL#
StringIndex=1
Download=1
[mHubbleNow]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url=#HubbleNow#
RegExp="(?siU)<enclosure url="(.*)" length="
StringIndex=1
Download=1
[mCleanRoomWebcam]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=300
Url=#CleanRoomURL#
StringIndex=1
Download=1
[mImageOfTheDay]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url="#ImageOfTheDayURL#"
RegExp="(?siU)(?(?=.*<IMG SRC).*<IMG SRC="(.*)").*<center>.*<b>(.*)</b>"
StringIndex=1
Download=1
[mImageOfTheDayTitle]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=1800
Url="#ImageOfTheDayTitleUrl#"
RegExp="(?siU)<IMG SRC=\"(.*)\".*<b>(.*)<"
StringIndex=2
[Image]
Meter=Image
MeasureName=#CurrentImageMeasure#
X=8
Y=8
W=([mMouseX]-12)
H=([mMouseY]-12)
PreserveAspectRatio=2
LeftMouseUpAction=["[mLink]"]
DynamicVariables=1
Group=Sizable
[CornerUL]
Meter=Image
ImageName=#@#Images\Backgrounds\InnerCornerUL.png
ImageTint=#CardColor#
X=8
Y=8
[CornerLL]
Meter=Image
ImageName=#@#Images\Backgrounds\InnerCornerUL.png
ImageTint=#CardColor#
ImageFlip=Vertical
X=8
Y=(4+[Image:H])
DynamicVariables=1
Group=Sizable
[CornerUR]
Meter=Image
ImageName=#@#Images\Backgrounds\InnerCornerUR.png
ImageTint=#CardColor#
X=(4+[Image:W])
Y=8
DynamicVariables=1
Group=Sizable
[CornerLR]
Meter=Image
ImageName=#@#Images\Backgrounds\InnerCornerUR.png
ImageTint=#CardColor#
ImageFlip=Vertical
X=(4+[Image:W])
Y=(4+[Image:H])
DynamicVariables=1
Group=Sizable
[ResizeBG]
Meter=Image
ImageName=#@#Images\Arrows\ResizeBG.png
ImageTint=#IconsColor1#
LeftMouseDownAction=[!CommandMeasure mMouse "Start"]
X=([mMouseX]-20)
Y=([mMouseY]-20)
DynamicVariables=1
Group=Sizable | Resize
MouseActionCursorName=DiagonalResize.cur
Hidden=1
[ResizeArrows]
Meter=Image
ImageName=#@#Images\Arrows\ResizeArrows.png
ImageTint=#IconsColor2#
X=r
Y=r
DynamicVariables=1
Group=Sizable | Resize
Hidden=1
[TitleBg1]
Meter=Image
SolidColor=#CardColor#
X=8
Y=8
W=[Image:W]
H=22
DynamicVariables=1
Group=Sizable | Title
Hidden=1
[TitleBg2]
Meter=Image
ImageName=#@#Images\TextBars\TextBar17.png
ImageTint=#TextBarsColor#
X=8
Y=8
AntiAlias=1
DynamicVariables=1
Group=Sizable | Title
Hidden=1
[TitleBg3]
Meter=Image
ImageName=#@#Images\TextBars\TextBar17.png
ImageTint=#TextBarsColor#
X=([Image:W]-47)+8
Y=r
AntiAlias=1
DynamicVariables=1
Group=Sizable | Title
Hidden=1
[TitleBg4]
Meter=Image
SolidColor=#TextBarsColor#
AntiAlias=1
X=(([mMouseX]/2)-([BottomMiddle:W]/2))+16
Y=r
W=([Card:W])-48
H=18
DynamicVariables=1
Group=Sizable | Title
Hidden=1
[Title]
Meter=String
MeterStyle=TextStyle
MeasureName=mImageOfTheDayTitle
X=(16+[Image:W])/2
Y=1r
W=([Card:W])-48
H=18
ClipString=1
DynamicVariables=1
Group=Sizable | Title
Hidden=1
[InfoCalc]
Measure=Calc
Formula=([mMouseY]+4)
DynamicVariables=1
Group=Sizable
[Info]
Meter=String
Text=Skin Height: [InfoCalc]#CRLF#Current Monitor: #CurrMon##CRLF#Current Monitor Height: #CurrMonHeight#
AntiAlias=1
X=-280
Y=-200
FontFace=Courier New
FontColor=255,255,255
SolidColor=0,0,0
StringAlign=Right
DynamicVariables=1
Group=Sizable
[Settings]
Meter=Image
ImageName=#@#Images\Dot6.png
ImageTint=#IconsColor1#
LeftMouseUpAction=[!WriteKeyValue Variables SettingsConfiguration "NASA" #Var#"][!ActivateConfig "#i0#" "Settings.ini"][!Refresh #i0#]
MouseOverAction=[!SetOption Settings ImageTint #IconsColor2#][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption Settings ImageTint #IconsColor1#][!UpdateMeter *][!Redraw]
MouseActionCursor=1
DynamicVariables=1
AntiAlias=1
X=(4+[Image:W])
Y=-2
W=14
Hidden=1
Group=Nav
Re: Demonstrating the Mouse plugin
Posted: September 8th, 2017, 9:38 am
by theimmersion
Amazing! Just what we needed. I like how the plugin has dedicated functions LeftMouseDragAction and volume slider runs smooth even on Skin Update=500. Tho the round volume slider is buggy but it might just be me. Cant move the skin and it opens the rainmeter install dir for some reason. xD
Re: Demonstrating the Mouse plugin
Posted: September 8th, 2017, 9:58 am
by theimmersion
balala wrote:I don't contest a such plugin would be helpful in many cases, however a slider can be created even without any plugin.
Well, yes but with a dedicated plugin that has dedicated actions, you can skip a lot of conditions and checks and code.
The simpler and smaller the code, the less there is to brake, the less there is performance hit etc, and the easier is for newbies to jump into it without prior knowledge and calculations etc etc needed. And thats what Rainmeter is all about, user friendly and easy to jump into. PROFIT!
At least, is my guess.
Re: Demonstrating the Mouse plugin
Posted: September 8th, 2017, 10:02 am
by balala
theimmersion wrote:Well, yes but with a dedicated plugin that has dedicated actions, you can skip a lot of conditions and checks and code.
The simpler and smaller the code, the less there is to brake, the less there is performance hit etc, and the easier is for newbies to jump into it without prior knowledge and calculations etc etc needed. And thats what Rainmeter is all about, user friendly and easy to jump into. PROFIT!
At least, is my guess.
Yeah, you're perfectly right. As I said, I don't contest the importance of a such plugin.
Re: Mouse plugin from NighthawkSLO
Posted: May 20th, 2018, 5:23 pm
by kyriakos876
Hello, I was wondering if you can have MouseMoveAction=... and LeftMouseDragAction=... in the same measure.
Re: Mouse plugin from NighthawkSLO
Posted: May 20th, 2018, 5:37 pm
by kyriakos876
Nevermind, I figured that out, but I think I found a bug. I don't know if it's caused from that plugin, but I'm pretty sure it is.
So, load the attached skin and have a YouTube song play in chrome. Then, mouse over the skin and in the progress bar (the red bar) click and drag back and forth for a while, release and click and drag again(click and drag a couple of times until it happens). You will notice the bug randomly. A window opens in "Photos" app of windows, and it displays a random .png that is included in the skin's
#@#Images\. This is the log:
bufgubgbug.png
and the file is there, with that exact name. I don't know why it's trying to open it though or why sometimes it actually opens it and sometimes it cannot...
EDIT: I didn't include the plugins or the chrome extension needed, as I suppose that those that are able to figure it out already have them. If not, let me know and I'll try find the distributed plugins and load them in the skin.
Re: Mouse plugin from NighthawkSLO
Posted: February 13th, 2019, 1:48 am
by raiguard
I can't believe I never knew about this plugin... I need to browse the Rainmeter forums more!
draggable sliders.gif
Anyway, I encountered a strange bug while developing with this plugin, but I can't reproduce it. When I was implementing the song progress slider, I went and renamed one of the variables I was using in the other slider (
sliderHandleX -> volumeSliderHandleX). When I did this, it started spitting out strange errors to the log, in which parts of the section variable and standard variable names used in the measure were replaced with random Chinese characters. I immediately thought this was a file encoding issue, but when I viewed the file in a pure UTF-8 environment, everything was fine. I eventually fixed the issue by restarting Rainmeter.
I haven't been able to reproduce the issue yet, but I'll keep trying. As an aside, I've noticed that as you use the sliders more and more, the plugin becomes less and less performant, to the point where it'll lag Rainmeter for several seconds when you're trying to drag. Once again, restarting Rainmeter fixes the issue.
I'll update this post if I find out anything more.