It is currently March 29th, 2024, 10:19 am

Move skin with mouse

Get help with creating, editing & fixing problems with skins
scottsq
Posts: 5
Joined: June 22nd, 2017, 6:11 pm

Move skin with mouse

Post by scottsq »

Hi everyone,

Is it possible to move a skin with mouse's desktop positions ? Like if the mouse is at the left of the screen, the skin move to the right...
I searched on Rainmeter's manual some elements but i didn't understand everything (maybe because i'm bad in english and i begin programing :???: ).
I hope i was understandable, i don't speak often English... :)
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Move skin with mouse

Post by mak_kawa »

Just one solution, use MouseXY plugin.

https://forum.rainmeter.net/viewtopic.php?p=126924

Below is a sample code which moves other skin following mouse position. Modify as you like.

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,1

[MeasureMouseX]
Measure=Plugin
Plugin=MouseXY
Dimension=X
MaxValue=#SCREENAREAWIDTH#

[MeasureMouseY]
Measure=Plugin
Plugin=MouseXY
Dimension=Y
MaxValue=#SCREENAREAHEIGHT#

[MoveMeasure]
Measure=Calc
Formula=1
IfConditionMode=1
IfCondition=MoveMeasure=1
IfTrueAction=[!Move ([MeasureMouseX]+10) ([MeasureMouseY]+10) yourskin]
DynamicVariables=1

[DummyMeter]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=1
H=1
EDIT: original code may disable mouse operation in some situation, sorry.
scottsq
Posts: 5
Joined: June 22nd, 2017, 6:11 pm

Re: Move skin with mouse

Post by scottsq »

Thank you, mak_kawa, for this fast answer ! :)
I'll try it now ! :thumbup:
scottsq
Posts: 5
Joined: June 22nd, 2017, 6:11 pm

Re: Move skin with mouse

Post by scottsq »

Hi again !

Finaly, when i move the mouse, the skin follows the mouse. But when i modify the code to move the skin to the right when the mouse is at left of the screen, the skin just block at (0,0) :(
What i simply modified is :

Code: Select all

[MoveMeasure]
Measure=Calc
Formula=1
IfConditionMode=1
IfCondition=MeasureMouseX<10
IfTrueAction=[!Move (x+10) y]
DynamicVariables=1
I thought incrementing x by 10 would move the skin 10 pixels to the right, but it wont... Is it a wrong notation ? Or maybe we have to create a new variable ? :confused:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Move skin with mouse

Post by balala »

scottsq wrote:I thought incrementing x by 10 would move the skin 10 pixels to the right, but it wont... Is it a wrong notation ? Or maybe we have to create a new variable ? :confused:
What you mean by =[!Move (x+10) y]? In Rainmeter (unlike in any programming languages) you can't simply use x and y, as you did.
If they are variables, the correct form of the bang would be: =[!Move "(#x#+10)" "#y#"] (note that I also added some quotation marks, which are preferably to be used).
If they are not, then indeed, would be a good idea to create those variables.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Move skin with mouse

Post by mak_kawa »

Hi scottsq

To solve the problem efficiently, please post the whole flow of your working code.
scottsq
Posts: 5
Joined: June 22nd, 2017, 6:11 pm

Re: Move skin with mouse

Post by scottsq »

It works with some added variables !

Hereis the full code, which is fonctional :

Code: Select all

[Rainmeter]
Update=25


[Variables]
A=0
B=0


[MoveMeasure]
Measure=Calc
Formula=1
IfConditionMode=1
IfCondition=(MeasureMouseX<10) && (#A#<0)
IfTrueAction=[!Move "(#A#+10)" "(#B#)"][!setvariable A "(#A#+10)"]
IfConditionMode2=1
IfCondition2=(MeasureMouseX>1360) && (#A#>-1032)
IfTrueAction2=[!Move "(#A#-10)" "(#B#)"][!setvariable A "(#A#-10)"]
IfConditionMode3=1
IfCondition3=(MeasureMouseY>763) && (#B#>-1027)
IfTrueAction3=[!Move "(#A#)" "(#B#-10)"][!setvariable B "(#B#-10)"]
IfConditionMode4=1
IfCondition4=(MeasureMouseY<10) && (#B#<-1)
IfTrueAction4=[!Move "(#A#)" "(#B#+10)"][!setvariable B "(#B#+10)"]

IfCondition5=#A#<-1033


DynamicVariables=1


[MeterBackground]
Meter=image
ImageName="path\the_image.png"
antialias=1
x=0
y=0
dynamicvariables=1


[MeasureMouseX]
Measure=Plugin
Plugin=MouseXY
Dimension=X
MaxValue=#SCREENAREAWIDTH#


[MeasureMouseY]
Measure=Plugin
Plugin=MouseXY
Dimension=Y
MaxValue=#SCREENAREAHEIGHT#

If you tell me how to post a video here, i can show you the results :)
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Move skin with mouse

Post by mak_kawa »

Hi scottsq
i can show you the results
No, not necessary for me. :-) I am glad that your code is now workable.

Some points I have noticed.

1. IfConditionMode2=1 IfConditionMode3=1 IfConditionMode4=1 are needless at all, because IfConditionMode=1 is effective throughout IfConditionN part in one measure.

2. dynamicvariables=1 in [MeterBackground] is unnecessary, because no variables are in this meter.
scottsq
Posts: 5
Joined: June 22nd, 2017, 6:11 pm

Re: Move skin with mouse

Post by scottsq »

Ok thank you for those tips ! :thumbup:

And thank you all for helping me ! it was really helpfull :great: