It is currently May 6th, 2024, 9:32 am

Stuck on moving skins. Any response appreciated!

Get help with creating, editing & fixing problems with skins
melik1
Posts: 7
Joined: May 5th, 2012, 10:48 pm

Stuck on moving skins. Any response appreciated!

Post by melik1 »

Hey! :welcome:
Just registered but I've had Rainmeter for a while now and must say that I really love it. Awesome work.

Anyhow, I'm having a problem with a skin I've been trying to make for the last hour(s).

I know what it should do, but I don't know how it should be done exactly.
What I want is to make a skin I've modified to appear at the center of the screen on startup, then move to a specific location on the screen.

As a Java programmer, I know how this could be done in Java, but I'm not familiar with Rainmeter scripts (also integrated with Lua scripting).

What I have so far:

Code: Select all

[Rainmeter]
Update=1000

;[MeasureLuaScript]
;Measure=Script
;ScriptFile=icontest.lua

[Variables]
FontName=Stark

[Square_middle]
Meter=IMAGE
Solidcolor=0,0,0
X=0
Y=0
W=100
H=55

[IconTest_Text]
Meter=String
X=50
Y=5
FontColor=255, 255, 255
FontSize=12
FontFace=#FontName#
StringStyle=BOLD
StringAlign=CENTER
AntiAlias=1
Text="Task Manager"
Hidden=1



[IconTest_Icon]
Meter=Image
ImageName=shutdownw.png
X=35
Y=15r
MouseOverAction=!execute [!RainmeterShowMeter IconTest_Text][!RainmeterRedraw]
MouseLeaveAction=!execute [!RainmeterHideMeter IconTest_Text][!RainmeterRedraw]
The code above creates a skin (more specifically a black square) that I want to automatically position itself to other coordinates.

(Notice how I've commented out the Lua script measure as it was solely for experimenting)

I've also looked around bangs and browsed various forum threads but after a while of struggling and looking for applied examples in other .ini I couldn't find a way to implement the movement bang(s).

Also, if this skin would move from A to B, would it directly appear at the end destination or would it move, unit for unit across the screen? As I said; I don't know how it works.

As mentioned, any response would be appreciated and a solution would be even more!


Regards!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Stuck on moving skins. Any response appreciated!

Post by jsmorley »

Move when? If you have it move as soon as you load the skin, you will never even see it. For all intents and purposes it will just load up in the final position.
melik1
Posts: 7
Joined: May 5th, 2012, 10:48 pm

Re: Stuck on moving skins. Any response appreciated!

Post by melik1 »

On initialize (or more specifically) on startup/updating the skin.
Okay, but is there then a way to implement a delay to the movement, so it's possible to see how the skin moves to the specified coords?

Edit: It's pretty difficult to express this, but what I'm looking for is a way to move a skin with a delay, so you can actually see it moving across the screen and not just appear at the given coords. Writing code that will perform this action.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Stuck on moving skins. Any response appreciated!

Post by jsmorley »

You can play with the math as you like, but here is a little skin starts centered, then moves a square in little increments 500px left and up, and then stops.

Code: Select all

[Rainmeter]
Update=100

[MeterSquare]
Meter=Image
SolidColor=179,255,171
W=200
H=200
X=(((#SCREENAREAWIDTH# - [MeasureMove]) / 2) - 100)
Y=(((#SCREENAREAHEIGHT# - [MeasureMove]) / 2) - 100)
DynamicVariables=1

[MeasureMove]
Measure=Calc
Formula=([MeasureMove] % 500) + 10
DynamicVariables=1
IfEqualValue=490
IfEqualAction=!SetOption MeasureMove UpdateDivider -1

melik1
Posts: 7
Joined: May 5th, 2012, 10:48 pm

Re: Stuck on moving skins. Any response appreciated!

Post by melik1 »

Amazing, the algorithm's all I needed. :)
I'll be fiddling with the values now and I might share it depending on the outcome of it.

Once again, thanks, that code pretty much addressed my issue.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Stuck on moving skins. Any response appreciated!

Post by jsmorley »

Glad to help. You are going to find that Rainmeter is (for now) not terribly good at animating things, and it will be hard to work this approach into a robust skin with lots of elements while having any movement be both smooth and not tear up your CPU, but this is at least one way to do it.

I'd be tempted indeed to get out to Lua to do this myself to be honest, as you can use things like GetX and SetX and !Redraw to have a lot more control over things and probably get a somewhat smoother action without having to set the overall Update rate of the skin really low or have the movement be in large increments.
melik1
Posts: 7
Joined: May 5th, 2012, 10:48 pm

Re: Stuck on moving skins. Any response appreciated!

Post by melik1 »

Exactly.

As you can see in the following code sample, I've increased the increments in the positioning formula by +20 instead of +10 while also lowering the Update to lowest integer possible, forcing the skin to update as much as it can in as little time possible, hence making it as smooth as it gets.

P.S. Some values might be 'incorrect' or not make much sense, but they are there for troubleshooting at the moment :)

Code: Select all

[Rainmeter]
Update=0


[MeterSquare]
Meter=Image
SolidColor=255,255,255
W=100
H=55
X=((#SCREENAREAWIDTH#/2 - [MeasureMoveX]) -50)
Y=(#SCREENAREAHEIGHT#/2 + [MeasureMoveY])
DynamicVariables=1
LeftMouseDownAction=!Execute [%windir%\System32\taskmgr.exe][!RainmeterRedraw]



[MeasureMoveY]
Measure=Calc
Formula=([MeasureMoveY] % 200) + 20
DynamicVariables=1
IfEqualValue=200
IfEqualAction=!SetOption MeasureMoveY UpdateDivider -1


;-- two measures as separate movement values are intended. 
[MeasureMoveX]
;-- UpdateDivider=-1 because I want the x-movement to stay as of now
UpdateDivider=-1
Measure=Calc
Formula=([MeasureMoveX] % 200) + 20
DynamicVariables=1
IfEqualValue=180
IfEqualAction=!SetOption MeasureMoveX UpdateDivider -1
Possibly using more resources this way than if you'd integrate an external Script engine with it.

However, using this code, a skin can only be moved upwards in the Y-axis but never downwards as it tends to disappear on its way down.. Very, very strange.. Could it be an unsupported Rainmeter error or is there a fault in the current code?

Edit: Feel free to test it, you might laugh because it's acting very weird :) But be sure to change the Update to >=500 if you want to actually see the skin before it struts off.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Stuck on moving skins. Any response appreciated!

Post by jsmorley »

melik1 wrote:Exactly.

As you can see in the following code sample, I've increased the increments in the positioning formula by +20 instead of +10 while also lowering the Update to lowest integer possible, forcing the skin to update as much as it can in as little time possible, hence making it as smooth as it gets.

P.S. Some values might be 'incorrect' or not make much sense, but they are there for troubleshooting at the moment :)

Code: Select all

[Rainmeter]
Update=0


[MeterSquare]
Meter=Image
SolidColor=255,255,255
W=100
H=55
X=((#SCREENAREAWIDTH#/2 - [MeasureMoveX]) -50)
Y=(#SCREENAREAHEIGHT#/2 + [MeasureMoveY])
DynamicVariables=1
LeftMouseDownAction=!Execute [%windir%\System32\taskmgr.exe][!RainmeterRedraw]



[MeasureMoveY]
Measure=Calc
Formula=([MeasureMoveY] % 200) + 20
DynamicVariables=1
IfEqualValue=200
IfEqualAction=!SetOption MeasureMoveY UpdateDivider -1


;-- two measures as separate movement values are intended. 
[MeasureMoveX]
;-- UpdateDivider=-1 because I want the x-movement to stay as of now
UpdateDivider=-1
Measure=Calc
Formula=([MeasureMoveX] % 200) + 20
DynamicVariables=1
IfEqualValue=180
IfEqualAction=!SetOption MeasureMoveX UpdateDivider -1
Possibly using more resources this way than if you'd integrate an external Script engine with it.

However, using this code, a skin can only be moved upwards in the Y-axis but never downwards as it tends to disappear on its way down.. Very, very strange.. Could it be an unsupported Rainmeter error or is there a fault in the current code?

Edit: Feel free to test it, you might laugh because it's acting very weird :) But be sure to change the Update to >=500 if you want to actually see the skin before it struts off.
Set DynamicWindowSize=1 in the [Rainmeter] section and that should help with moving it down. Also, you might want to move the meter below the measures in the skin, so you don't get an initial error when you first load / refresh.

P.S. Be careful about Update=0. That basically is selling your CPU into complete slavery to the skin. "Let my cycles goooooo..."
User avatar
Seahorse
Posts: 1175
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Stuck on moving skins. Any response appreciated!

Post by Seahorse »

jsmorley wrote:Rainmeter is (for now) not terribly good at animating things
Which implies changes are coming, care to elaborate... :thumbup:
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Stuck on moving skins. Any response appreciated!

Post by jsmorley »

Seahorse wrote: Which implies changes are coming, care to elaborate... :thumbup:
I could, but then I'd have to kill you.