Mouse Variables
Mouse variables are a special function to return the X and Y position of the mouse cursor when a mouse action takes place.
The position is relative to the meter that has the mouse click or scroll action, or the skin if used in the [Rainmeter] section.
There are two variants of the function.
- $MouseX$ and $MouseY$
Contains the current X and Y position of the mouse in pixels relative to the meter or skin. - $MouseX:%$ and $MouseY:%$
Contains the current X and Y position of the mouse as a percentage relative to the meter or skin.
Usage
The variables are only created and used in the context of a mouse click or scroll action. Primarily, they will be used as a parameter to a Bang. For instance:
LeftMouseUpAction=[!SetOption SomeMeter X $MouseX$][!UpdateMeter *][!Redraw]
LeftMouseUpAction=!CommandMeasure ScriptMeasure GetRGB($MouseX$,$MouseY$)
Notes: The values returned are not the mouse position on the screen, but are pixels or a percentage relative to the meter or skin with the mouse action. They are also not general purpose variables, and when used outside the context of a mouse action on a meter or the skin, will not contain a value.
$MouseX$
-
X position of the mouse cursor as a number of pixels relative to the meter or skin with the mouse action.
$MouseY$
-
Y position of the mouse cursor as a number of pixels relative to the meter or skin with the mouse action.
$MouseX:%$
-
X position of the mouse cursor as a percentage relative to the meter or skin with the mouse action.
$MouseY:%$
-
Y position of the mouse cursor as a percentage relative to the meter or skin with the mouse action.
Example
[Rainmeter] |