It is currently October 9th, 2024, 7:31 pm
Lua Script Mouse Position
-
- Posts: 5
- Joined: September 8th, 2023, 5:07 pm
Lua Script Mouse Position
Hello, I'd like to use a lua script to get the current mouse coordinates every update (and then use that in the rainmeter code). I'm not sure how to get the actual mouse coordinates in lua. I am very new to lua and Google isn't being helpful. Thanks!
-
- Rainmeter Sage
- Posts: 16645
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Lua Script Mouse Position
You don't need a Lua script for this, but a plugin. Namely you need the Mouse plugin, available here. Install it.FoxInTheClouds wrote: ↑September 18th, 2023, 6:34 pm I'd like to use a lua script to get the current mouse coordinates every update (and then use that in the rainmeter code).
Then you need to add the following measure and meter to your code:
Code: Select all
[MeasureMouse]
Measure=Plugin
Plugin=Mouse
DynamicVariables=1
MouseMoveAction=[!SetVariable PosX "$mouseX$"][!SetVariable PosY "$mouseY$"][!UpdateMeter "MeterPos"][!Redraw]
RelativeToSkin=1
[MeterPos]
Meter=STRING
X=10
Y=10
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=#PosX# | #PosY#
DynamicVariables=1
Please let me know if you don1t know how to install the plugin.
-
- Posts: 5
- Joined: September 8th, 2023, 5:07 pm
Re: Lua Script Mouse Position
I don't really want to use a plugin if possible because I am giving the skin to non-techy people who often don't have the right dependecies (C++ runtime, .NET) and have run into issues.
-
- Rainmeter Sage
- Posts: 16645
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Lua Script Mouse Position
Sorry, but in this case, that's it. Not sure if you can do this by a Lua script.FoxInTheClouds wrote: ↑September 18th, 2023, 8:16 pm I don't really want to use a plugin if possible because I am giving the skin to non-techy people who often don't have the right dependecies (C++ runtime, .NET) and have run into issues.
-
- Rainmeter Sage
- Posts: 8397
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Lua Script Mouse Position
A Rainmeter plugin is just a .dll file that uses the same dependencies as Rainmeter itself, and can easily be included into your skin package when you pack your skin for release. In other words, all these non-technical people would have to do is to install your packaged skin via double clicking on it's .rmskin package, and theyll have everything you included there (the plugin as well) ready for use by your code.FoxInTheClouds wrote: ↑September 18th, 2023, 8:16 pm I don't really want to use a plugin if possible because I am giving the skin to non-techy people who often don't have the right dependecies (C++ runtime, .NET) and have run into issues.
-
- Posts: 5
- Joined: September 8th, 2023, 5:07 pm
Re: Lua Script Mouse Position
I figured out the error I was getting on other computers, it was a different thing. Turns out a plugin works fine.
Thanks for the help.
Thanks for the help.
-
- Rainmeter Sage
- Posts: 8397
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Lua Script Mouse Position
FoxInTheClouds wrote: ↑September 19th, 2023, 3:53 pm I figured out the error I was getting on other computers, it was a different thing. Turns out a plugin works fine.
Thanks for the help.
-
- Rainmeter Sage
- Posts: 16645
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Lua Script Mouse Position
FoxInTheClouds wrote: ↑September 19th, 2023, 3:53 pm I figured out the error I was getting on other computers, it was a different thing. Turns out a plugin works fine.
Thanks for the help.
You're welcome...