It is currently March 28th, 2024, 6:24 pm

Mouse plugin from NighthawkSLO

Plugins and Addons popular with the Community
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 3rd, 2020, 9:06 am You can add a LeftMouseUpAction option (beside the LeftMouseDownAction) and move the appropriate bangs there. For instance something like this:

Code: Select all

[MeasureMouse]
...
LeftMouseDownAction=[!CommandMeasure MeasureMouse "Stop"][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 247,247,247,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition "MeasureWin7Audio = -1"][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!HideMeter MeterPercent][!Redraw]
I'm surprised if it does.
Yeah, naturally I tried that, but LeftMouseUpAction would need some kind of start or stop command. That's what is causing the skin context menu to open and all the hovering and clicking to stop working. When LeftMouseDownAction of the slider says "Start" and LeftMouseDownAction of MeasureMouse says "Stop" I'm pretty sure the actual plugin never gets stopped. It's still running and that's why hovering and clicking stops working, until I click on something.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

cthunsthrall wrote: December 3rd, 2020, 2:26 pm but LeftMouseUpAction would need some kind of start or stop command. That's what is causing the skin context menu to open and all the hovering and clicking to stop working.
But what if you move the !CommandMeasure bangs as well from the LeftMouseDownAction to the LeftMouseUpAction option?
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 3rd, 2020, 2:53 pm But what if you move the !CommandMeasure bangs as well from the LeftMouseDownAction to the LeftMouseUpAction option?
That's what I did. If LeftMouseDownAction is "Stop", then it doesn't seem to matter whether LeftMouseUpAction is "Stop" or "Start". (or even if it has a !CommandMeasure bang at all) The clicking will work, but then it's like it continues running after releasing the mouse. So none of the hovering features work, and right-clicking opens the skin context menu instead of the custom context menu. That is, until I click something outside of the skin. This gave me the impression that the "Start" is triggering after the "Stop" so it's not actually stopping the plugin. After clicking once, it just keeps running. MeterSlideBack starts the plugin on LeftMouseDown, and MeasureMouse stops it on LeftMouseDown.

So it looks like MeasureMouse's action is executing before MeterSlideBack's for some reason. If I reverse them, then I'm right back where I started where dragging works but clicking doesn't. I also tried swapping MeterSlideBack's actions, so it starts on LeftMouseUp and stops on LeftMouseDown. That has the same result of messing up the context menu and hovering. So I'm not really sure what else to try
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 3rd, 2020, 2:53 pm But what if you move the !CommandMeasure bangs as well from the LeftMouseDownAction to the LeftMouseUpAction option?
Okay wait, I actually figured out a way to get clicking to work without indefinitely running the plugin. I only changed this (relative to the original skin I linked)

Code: Select all

[MeasureMouse]
Measure=Plugin
Plugin=Mouse
LeftMouseDragAction=[!SetOption MeterSlider X "(Clamp(($MouseX$-15),10,200))"][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 255,255,255,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition ""][!ShowMeter MeterPercent][!UpdateMeter "MeterPercent"][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]
LeftMouseDownAction=[!CommandMeasure MeasureMouse "Start"][!SetOption MeterSlider X "(Clamp(($MouseX$-15),10,200))"][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 255,255,255,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition ""][!ShowMeter MeterPercent][!UpdateMeter "MeterPercent"][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!CommandMeasure MeasureMouse "Stop"][!HideMeter MeterPercent][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 247,247,247,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition "MeasureWin7Audio = -1"][!UpdateMeter *][!Redraw]
RelativeToSkin=1
RequireDragging=0
DynamicVariables=1
So I set RequireDragging=0, then I added a LeftMouseDownAction and gave it the LeftMouseDragAction's bangs, plus [!CommandMeasure MeasureMouse "Start"]. This seems to work correctly.

The problem is that now the clicking works anywhere within the skin, so clicking on empty space triggers it. I only really want it to activate if I click the slider or the slide bar (MeterSlideBack). I can make the skin a little smaller but there still needs to be room for the percent meter. I tried moving the Up and Down actions to [MeterSlideBack], but they don't work there for some reason. I assume that's because the variable $MouseX$ does not exist within their scope and is only known to [MeasureMouse]? In other words, they're not getting updated as to the definition of $MouseX$ so the command to set MeterSlider X based on the mouse location has no effect. I tried setting a global variable %MouseX% and using [MeasureMouse] to update it, but it didn't work for some reason. I don't really know the right syntax for defining a global variable as a function of a temporary variable.

edit: Actually, now I think of it, $MouseX$ should be globally available since the built-in mouse actions use it too... So I really have no idea why those bangs aren't working in [MeterSlideBack]. Maybe they need to trigger the update of a certain measure.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

cthunsthrall wrote: December 3rd, 2020, 6:43 pm The problem is that now the clicking works anywhere within the skin, so clicking on empty space triggers it.
Remove the LeftMouseDownAction and LeftMouseUpAction options of the [MeasureMouse] measure, then add the following MouseOverAction and MouseLeaveAction options to the [MeterSlideBack] meter:

Code: Select all

[MeterSlideBack]
...
MouseOverAction=[!SetOption MeasureMouse LeftMouseDownAction """[!CommandMeasure MeasureMouse "Start"][!SetOption MeterSlider X "(Clamp(($MouseX$-15),10,200))"][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 255,255,255,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition ""][!ShowMeter MeterPercent][!UpdateMeter "MeterPercent"][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]"""][!SetOption MeasureMouse LeftMouseUpAction """[!CommandMeasure MeasureMouse "Stop"][!HideMeter MeterPercent][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 247,247,247,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition "MeasureWin7Audio = -1"][!UpdateMeter *][!Redraw]"""][!UpdateMeasure "MeasureMouse"]
MouseLeaveAction=[!SetOption MeasureMouse LeftMouseDownAction "[]"][!SetOption MeasureMouse LeftMouseUpAction "[]"][!UpdateMeasure "MeasureMouse"]
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 3rd, 2020, 7:06 pm Remove the LeftMouseDownAction and LeftMouseUpAction options of the [MeasureMouse] measure, then add the following MouseOverAction and MouseLeaveAction options to the [MeterSlideBack] meter:

Code: Select all

[MeterSlideBack]
...
MouseOverAction=[!SetOption MeasureMouse LeftMouseDownAction """[!CommandMeasure MeasureMouse "Start"][!SetOption MeterSlider X "(Clamp(($MouseX$-15),10,200))"][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 255,255,255,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition ""][!ShowMeter MeterPercent][!UpdateMeter "MeterPercent"][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]"""][!SetOption MeasureMouse LeftMouseUpAction """[!CommandMeasure MeasureMouse "Stop"][!HideMeter MeterPercent][!SetOption MeterSlider Shape "Rectangle 5,0,20,20 | Fill Color 247,247,247,255 | StrokeWidth 0"][!SetOption MeasureWin7Audio IfCondition "MeasureWin7Audio = -1"][!UpdateMeter *][!Redraw]"""][!UpdateMeasure "MeasureMouse"]
MouseLeaveAction=[!SetOption MeasureMouse LeftMouseDownAction "[]"][!SetOption MeasureMouse LeftMouseUpAction "[]"][!UpdateMeasure "MeasureMouse"]
Pretty clever solution haha. That works pretty well, although it doesn't stop the LeftMouseDragAction, so if you click & hold somewhere outside the skin, the slider will move to the mouse position as soon as you move the mouse. And unfortunately if I use MouseLeaveAction to disable the LeftMouseDragAction like you did with the Up/Down actions, it causes the slider to stutter a bit while dragging it towards the left, I guess because the meters aren't updating as fast as the MouseLeaveAction is.

Another complication I noticed (whether we use MouseOver/Leave actions to disable the mouse bangs or not) is that disabling RequireDragging makes the mouse dragging no longer work outside the bounds of the skin. So basically if you click and drag the slider and move your mouse way down, it stops updating at a certain point. Which isn't a huge problem on its own, but because I have 2 sliders (backlight and volume) it causes this really weird issue. If you click and drag inside the backlight slider, and then move the mouse outside its bounds and over the volume slider, (without releasing the mouse button) you'll stop controlling the backlight slider and start controlling the volume slider. So it doesn't need me to actually mouse down inside the skin, merely clicking inside one of the 2 slider skins and holding the mouse button is enough to activate the bangs for *both* skins. Which means they teleport all over the place in practice.

Maybe there is some way around that, or maybe I will just have to only load one slider at a time. I guess I could make a context menu option that switches the slider from backlight to volume and vice versa.
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

I finally figured it out. I'm not really sure what the precise issue was but I think it was a timing issue and that's why a windows update changed it. Like the if conditions setting the mouse actions can be kinda sketchy if they're updated slower than the mouse events. Maybe what changed has to do with my monitor's refresh rate, because I changed from 144Hz to 120Hz. And after I figured the code out, I noticed that enabling hardware acceleration in rainmeter causes the issue to come back. When I first open rainmeter with hardware acceleration enabled, the sliders won't work, and I'll have to click them like 30 times to get them to start working. Whereas with hardware acceleration disabled, the sliders work right off the bat. Super weird so I thought maybe a graphics driver bug. But I tried uninstalling with DDU and rolling back to a driver from when everything was working fine, but didn't make any difference. So anyway I just decided to disable hardware acceleration. It does seem to increase GPU usage statistics, but in actual performance benchmarking it doesn't seem to make any difference. Like it's utilizing the GPU at 30% when idle but the GPU is still at its lowest power state so performance hit seems like a red herring. Anyway I'll attach the finished skins.
Attachments
Volume & Backlight_501.rmskin
(3.42 KiB) Downloaded 151 times
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

cthunsthrall wrote: December 6th, 2020, 2:15 am I finally figured it out. I'm not really sure what the precise issue was but I think it was a timing issue and that's why a windows update changed it. Like the if conditions setting the mouse actions can be kinda sketchy if they're updated slower than the mouse events. Maybe what changed has to do with my monitor's refresh rate, because I changed from 144Hz to 120Hz. And after I figured the code out, I noticed that enabling hardware acceleration in rainmeter causes the issue to come back. When I first open rainmeter with hardware acceleration enabled, the sliders won't work, and I'll have to click them like 30 times to get them to start working. Whereas with hardware acceleration disabled, the sliders work right off the bat. Super weird so I thought maybe a graphics driver bug. But I tried uninstalling with DDU and rolling back to a driver from when everything was working fine, but didn't make any difference. So anyway I just decided to disable hardware acceleration. It does seem to increase GPU usage statistics, but in actual performance benchmarking it doesn't seem to make any difference. Like it's utilizing the GPU at 30% when idle but the GPU is still at its lowest power state so performance hit seems like a red herring. Anyway I'll attach the finished skins.
Just tested, but unfortunately this isn't working for me (I'm talking about the Volume&Backlight\Volume\MouseVolume.ini skin, not about Volume&Backlight\Backlight\Backlight_Simple.ini). When I load the skin, it shows correctly the volume level, but when I first click it, the skin as well as the volume level jumps to 100% and there it stays. I can't reduce the volume level anymore through the skin, it simply refuses to do so. Due to time lack didn't study the code to check what is wrong there, but something is not good for sure. Please check.
cthunsthrall
Posts: 11
Joined: December 2nd, 2020, 3:51 pm

Re: Mouse plugin from NighthawkSLO

Post by cthunsthrall »

balala wrote: December 6th, 2020, 10:24 am Just tested, but unfortunately this isn't working for me (I'm talking about the Volume&Backlight\Volume\MouseVolume.ini skin, not about Volume&Backlight\Backlight\Backlight_Simple.ini). When I load the skin, it shows correctly the volume level, but when I first click it, the skin as well as the volume level jumps to 100% and there it stays. I can't reduce the volume level anymore through the skin, it simply refuses to do so. Due to time lack didn't study the code to check what is wrong there, but something is not good for sure. Please check.
Do you have hardware acceleration enabled? The mouse plugin stopped working for me the day I posted this stuff, and ultimately I wasn't able to fix it until I disabled hardware acceleration. They work perfectly for me but, strangely, only with acceleration disabled. I recently switched to a monitor with a different resolution and framerate so maybe that's relevant. Everything's a little hacky so I wouldn't expect it to work on every system, but I'm surprised the volume skin failed instead of the backlight skin. The volume skin works on all my computers (intel laptop, intel desktop, AMD desktop) but the backlight skin only works on certain monitors. Pretty weird.

Whatever's happening for you is probably a timing issue, because it's doing a lot of things at once. Like it's supposed to set the volume AND the slider position when you click, then for good measure the volume is supposed to adjust to the slider position, but at the same time the slider position is being adjusted by the volume (this to ensure it goes to the right position when the skin loads or something else perturbs the skin). I spent a lot of time trying to find a way to avoid this mess of overlapping and circular assignments, for obvious reasons.

When I first made the backlight slider, it didn't work to just swap the plugins, measures, and bangs for the backlight equivalents, because the timings are apparently quite different for Backlight.dll. I had to do some hacky shit I can't quite remember to make the Backlight slider work, so it's fundamentally different. So for that reason I assume the order of those operations is variable depending on the environment, and maybe that's why the sliders don't work. If you want to use the slider yourself I can try to fix it, but since I can't reproduce your issue it's probably not gonna be easy
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Mouse plugin from NighthawkSLO

Post by balala »

cthunsthrall wrote: December 29th, 2020, 11:41 am Do you have hardware acceleration enabled?
Yep, it is enabled for me.
Post Reply