It is currently March 29th, 2024, 11:12 am

NumOfDecimals in a image meter

Get help with creating, editing & fixing problems with skins
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

NumOfDecimals in a image meter

Post by StArL0rd84 »

To start of i wanna say, I know NumOfDecimals is for string meters only.
And let me explain what i want to do.

I am creating a recycle bin skin and when ever i empty it, i want a trayballon to appear.
LeftMouseUpAction=[#nircmd# trayballoon "Hello" "%1B have been freed" 1000]

The tray ballon appears, but the LeftMouseUpAction is in an image meter so i cant use NumOfDecimals=0.

So i tried to just use [mBinSize] which gives me the size of the bin, but the number had too many decimals.
Tried LeftMouseUpAction=[#nircmd# trayballoon "Hello" "[mBinSize:/1000000] have been freed" 1000]
But that just moves the decimal point to the left. (I am really bad at math)
freed.png
Also this wont add a MB or GB after the number, so im really confused to what direction i should take here.
Would be really nice if NumOfDecimals could be used in a image meter.

Any advice would be appreciated.
RecycleBinExample_1.0.rmskin
You do not have the required permissions to view the files attached to this post.
Last edited by StArL0rd84 on June 27th, 2017, 10:46 am, edited 1 time in total.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: NumOfDecimals in a image meter

Post by CyberTheWorm »

Try adding these 2, as long as there is text in the meter it should work.

Code: Select all

AutoScale=1
NumberOfDecimals=2
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: NumOfDecimals in a image meter

Post by jsmorley »

AutoScale and NumOfDecimals are of no use outside a String meter...

Code: Select all

LeftMouseUpAction=[!CommandMeasure mBinCount EmptyBinSilent][!UpdateMeasure mBinCount][!EnableMeasure MeasureRotate][!ShowMeter MeterRotate][#nircmd# trayballoon "Hello" "[mBinSize:/1024,2] kB have been freed" 1000][!UpdateMeter *][!Redraw]
https://docs.rainmeter.net/manual/variables/section-variables/#Decimals

P.S. That is a very clever and visibly cool skin!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NumOfDecimals in a image meter

Post by balala »

EDIT: Sorry jsmorley...
CyberTheWorm wrote:Try adding these 2, as long as there is text in the meter it should work.

Code: Select all

AutoScale=1
NumberOfDecimals=2
The correct option is NumOfDecimals, not NumberOfDecimals. But even so, it can't be used, because, as StArL0rd84 said, you should add it not to a string meter.
I'd propose another solution: I'd replace the appropriate bang of the LeftMouseUpAction option of the [Yes] meter, with something like the following one: [#nircmd# trayballoon "Hello" "[MeasureBin] have been freed" 1000]. In this case, [MeasureBin] is a new measure, which calculates the number of megabytes, rounding the appropriate value. Before you try the above solution, add the following Calc measure to your code:

Code: Select all

[MeasureBin]
Measure=Calc
Formula=( Round ( mBinSize / 1048576 ))
I used the Round function, to get rid the decimals. But note that I also rewrote the function, instead of the original [mBinSize:/1000000], I used mBinSize / 1048576. I did this, because when the bytes should be converted to Mbytes, we have to divide not with 1000*1000, but with 1024*1024 = 1048576.

First please give a try to this workaround. We'll handle the rest of your question later, for now let's see if this solution matches your needs.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: NumOfDecimals in a image meter

Post by jsmorley »

I think the [SectionVariable:/1024,2] kB approach is simpler... ;-)

If you want Megabytes, it can be:

Code: Select all

LeftMouseUpAction=[!CommandMeasure mBinCount EmptyBinSilent][!UpdateMeasure mBinCount][!EnableMeasure MeasureRotate][!ShowMeter MeterRotate][#nircmd# trayballoon "Hello" "[mBinSize:/1048576,2] MB have been freed" 1000][!UpdateMeter *][!Redraw]
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: NumOfDecimals in a image meter

Post by StArL0rd84 »

Wow all these replies!
I found that all of your solutions works for me.

Code: Select all

[MeasureBin]
Measure=Calc
Formula=( Round ( mBinSize / 1048576 ))

Code: Select all

[mBinSize:/1048576,2]
Going with the simple section variable.
And thank you jsmorley for the kind words :)

Rest of suite coming soon, just need final polish.
prev.png
You do not have the required permissions to view the files attached to this post.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NumOfDecimals in a image meter

Post by balala »

And finally, because in your initial request, you said:
StArL0rd84 wrote:Also this wont add a MB or GB after the number, so im really confused to what direction i should take here.
I supposed you'd like to convert the number of bytes, to either KBytes, MBytes or GBytes and also would like to add the appropriate measurement unit. Here is a workaround for this:
According to this, replace the [MeasureBin] measure, with the following one:

Code: Select all

[MeasureBin]
Measure=Calc
Formula=((( mBinSize / ( 1024 ** 3 )) >= 1 ) ? ( Round ( mBinSize / ( 1024 ** 3 ))) : ((( mBinSize / ( 1024 ** 2 )) >= 1 ) ? ( Round ( mBinSize / ( 1024 ** 2 ))) : ((( mBinSize / 1024 ) >= 1 ) ? ( Round ( mBinSize / 1024 )) : mBinSize )))
This measure will convert the number of bytes to the appropriate value, expressed in bytes, KB, MB or GB.
Also add the following measure to your code:

Code: Select all

[MeasureBinMult]
Measure=Calc
Formula=((( mBinSize / ( 1024 ** 3 )) >= 1 ) ? 3 : ((( mBinSize / ( 1024 ** 2 )) >= 1 ) ? 2 : ((( mBinSize / 1024 ) >= 1 ) ? 1 : 0 )))
Substitute="0":"B","1":"KB","2":"MB","3":"GB"
This measure, according to the substitution, will return B, KB, MB or GB.
The last thing you have to do is to replace the appropriate bang of the LeftMouseUpAction option of the [Yes] meter, with the following one: [#nircmd# trayballoon "Hello" "[MeasureBin][MeasureBinMult] have been freed" 1000].
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: NumOfDecimals in a image meter

Post by StArL0rd84 »

Code: Select all

[MeasureBin]
Measure=Calc
Formula=((( mBinSize / ( 1024 ** 3 )) >= 1 ) ? ( Round ( mBinSize / ( 1024 ** 3 ))) : ((( mBinSize / ( 1024 ** 2 )) >= 1 ) ? ( Round ( mBinSize / ( 1024 ** 2 ))) : ((( mBinSize / 1024 ) >= 1 ) ? ( Round ( mBinSize / 1024 )) : mBinSize )))

Code: Select all

[MeasureBinMult]
Measure=Calc
Formula=((( mBinSize / ( 1024 ** 3 )) >= 1 ) ? 3 : ((( mBinSize / ( 1024 ** 2 )) >= 1 ) ? 2 : ((( mBinSize / 1024 ) >= 1 ) ? 1 : 0 )))
Substitute="0":"B","1":"KB","2":"MB","3":"GB"
Holy moly balala! :jawdrop
Thank you so much for helping me with this!
I would NEVER have figured it out myself.
Well, maybe in a couple of years :D
I'll try and look a little deeper into it now, maybe i can learn a few things about formulas.
And gotta reed up on bits and bytes too while im at it.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </>))
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NumOfDecimals in a image meter

Post by balala »

StArL0rd84 wrote:[I'll try and look a little deeper into it now, maybe i can learn a few things about formulas.
I'm glad if you like it.
The basic idea is the following one: first I checked if the value returned by the [mBinSize] measure is greater then 1024^3 (which means 1024*1024*1024 = 1GB). If it is, the value returned by the [MeasureBin] measure is equal with ( Round ( mBinSize / ( 1024 ** 3 ))) (the value divided by 1024^3 and rounded).
If it's not, then it still can be greater then 1024^2 (meaning 1024*1024 = 1MB). If this second condition is met, the value of the [MeasureBin] measure is now equal with ( Round ( mBinSize / ( 1024 ** 2 ))) (the value divided by 1024^2 and rounded).
And finally if neither this condition isn't met, the last thing is to check if the value is greater then 1024 (1 KB). This time, if the condition is met, the returned value is ( Round ( mBinSize / 1024 )), otherwise it's of the order of magnitude of bytes, so the value of mBinSize measure must be returned.
The only meaning of the [MeasureBinMult] measure is to get the sufix (B, KB, MB or GB). I used similar conditions, the difference is that the returned values are 3, 2, 1 or 0, accordingly. This values are converted by the Substitute option into the appropriate strings.
And probably you got the idea of the modification made into the LeftMouseUpAction option of the [Yes] meter.

Feel free to come back if you have any further question.