It is currently April 18th, 2024, 10:25 am

Get mouse button states

Get help with creating, editing & fixing problems with skins
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Get mouse button states

Post by rbriddickk84 »

Greetings!

I've searching over the internet for forums and help unsuccessfully for solution to my issue.
I am trying to develope a "Drag & Drop" functionality in my skin, so 2 skins could change positions, like in program launching Docks.
Only one thing hold me back...okay, two things.
But if i would have a solution either one of those things, i would be cool. :)

1.: If there would be a solution for getting the mouse button states, like when it's released. I am not talking about LeftMouseUpAction, because if i hold down the left mouse button, and start to drag the skin, then the release of that button will be inactive. I've been trying some solutions in LUA, but no success so far.

2.: If the $MouseX$ and $MouseY$ values would be available outside of clicks and scrolls, like if i could get those values for a Calc Measure, then my issue would also be solved.

Thanks for any kind of help in advance!
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Get mouse button states

Post by balala »

rbriddickk84 wrote:1.: If there would be a solution for getting the mouse button states, like when it's released. I am not talking about LeftMouseUpAction, because if i hold down the left mouse button, and start to drag the skin, then the release of that button will be inactive. I've been trying some solutions in LUA, but no success so far.
I think the following simple solution will work. According to it, you have to use two variables, in this case I named them Left and Right. The value of them will be set by the appropriate LeftMouseDownAction / LeftMouseUpAction, respectively RightMouseDownAction / RightMouseUpAction:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
LeftMouseDownAction=[!SetVariable Left "1"][!UpdateMeter "MeterButtons"][!Redraw]
LeftMouseupAction=[!SetVariable Left "0"][!UpdateMeter "MeterButtons"][!Redraw]
RightMouseDownAction=[!SetVariable Right "1"][!UpdateMeter "MeterButtons"][!Redraw]
RightMouseUpAction=[!SetVariable Right "0"][!UpdateMeter "MeterButtons"][!Redraw]

[Variables]
Left=0
Right=0

[MeterButtons]
MeasureName=MeasureUptime
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Left: #LEFT##CRLF#Right: #Right#
DynamicVariables=1
0 always means the appropriate button is released, while 1 means pressed.
Isn't this a viable solution for your needs?
rbriddickk84 wrote:2.: If the $MouseX$ and $MouseY$ values would be available outside of clicks and scrolls, like if i could get those values for a Calc Measure, then my issue would also be solved.
Sorry, they are not! Read the first paragraph in the Usage section: https://docs.rainmeter.net/manual/variables/mouse-variables/, or the following: https://forum.rainmeter.net/viewtopic.php?p=85903#p85903
User avatar
theAzack9
Developer
Posts: 522
Joined: March 2nd, 2016, 6:23 pm

Re: Get mouse button states

Post by theAzack9 »

If Balalas answer didn't quite work you might be able to check out this plugin: https://github.com/NighthawkSLO/Mouse.dll
It should let you get the position of the mouse on the screen and check if left/right/middle mouse is clicked or not.

If Balalas answer is good enough i'd probably advice you to go with that solution since you won't need an external plugin, but if it doesn't then this should work :)

Edit: it is worth noting that there exist another plugin that will let you get the position of the mouse:
https://forum.rainmeter.net/viewtopic.php?f=18&t=22900&p=126924
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get mouse button states

Post by rbriddickk84 »

Thanks for the quick reply! :)

Sadly the first code is working, but if i make a LeftMouseDownAction, then the skin dragging functionality will be gone.
But if i make only a LiftMouseUpAction, then i can drag around the skin, but the UpAction will be ignored!

On the
balala wrote:Sorry, they are not! Read the first paragraph in the Usage section: https://docs.rainmeter.net/manual/varia ... variables/ , or the following: viewtopic.php?p=85903#p85903
comment, yeah, i knew that already :) that's why i wrote with "If" statement :D

This is why i am in checkmate :???:
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Get mouse button states

Post by balala »

rbriddickk84 wrote:This is why i am in checkmate :???:
No, you're not. Read theAzack9's above reply.
User avatar
rbriddickk84
Rainmeter Sage
Posts: 276
Joined: February 17th, 2014, 12:39 pm
Location: Hungary

Re: Get mouse button states

Post by rbriddickk84 »

Yes, i was posted my post the same time, when his post arrived :)

So thank you both the nice help!!! :D

I think the plugin will help! :) I downloaded it and it opens up a lots of possibilities for my other older skins too! :)

Thank you again both of you the cool helps! Appretiate it! :thumbup: