It is currently April 27th, 2024, 3:09 am

Using conditions in a 'Mail Checker' meter

Get help with creating, editing & fixing problems with skins
User avatar
kami
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Using conditions in a 'Mail Checker' meter

Post by kami »

Hi everyone, i'm trying to make a gmail checker.
I want to show a badge displaying the number of incoming not read mails (just like push notification in iphone).

First issue (can't solve by myself)
I want to display the badge if there is 1 new incoming mail or more and i want to hide the badge if there are no mails.

Second issue (can't solve by myself)
If the number of incoming mails is greater than 9, the badge should stretch and reposition itself
with the number centered within it.

Third issue (can't solve by myself)
Same thing if the number of incoming mails is greater than 99.

Here the code:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Url=https://username:password@gmail.google.com/gmail/feed/atom
RegExp="(?siU)<fullcount>(.*)</fullcount>"
Codepage=0
DownloadLogo=1
FontName=Arial
IconSize=130
BadgeSize=( 4000 / #IconSize# )
FontSize=( ( #BadgeSize# * 37 ) / 100 )
White=255, 255, 255, 255


============
; Measures
;===========

[MeasureRSSNews]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#Url#
RegExp=#RegExp#
Codepage=#Codepage#
Download=#DownloadLogo#
UpdateRate=1
StringIndex=4
FinishAction=!Execute [!RainmeterRedraw]

[MeasureTitle]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureRSSNews]
StringIndex=1
UpdateRate=1
DynamicVariables=1
IfEqualValue=0
IfEqualAction=!execute [!RainmeterHideMeter [MeterTitle]][!RainmeterHideMeter [MeterBadge]]
IfAboveValue=0
IfBelowAction=!execute [!RainmeterShowMeter [MeterTitle]][!RainmeterShowMeter [MeterBadge]]

;=========
; Meters
;=========
[MeterIcon]
Meter=IMAGE
X=0
Y=0
W=#IconSize#
PreserveAspectRatio=1
ImageName=Icons\Mailbox.png
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]

[MeterBadge]
Meter=IMAGE
X=5
Y=20
W=#BadgeSize#
PreserveAspectRatio=1
ImageName=Icons\Badge1.png
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]

[MeterTitle]
Meter=STRING
MeasureName=MeasureTitle
X=14
Y=25
FontColor=#White#
StringStyle=BOLD
FontSize=#FontSize#
FontFace=#FontName#
AntiAlias=1
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using conditions in a 'Mail Checker' meter

Post by jsmorley »

kami wrote:Hi everyone, i'm trying to make a gmail checker.
I want to show a badge displaying the number of incoming not read mails (just like push notification in iphone).

First issue (can't solve by myself)
I want to display the badge if there is 1 new incoming mail or more and i want to hide the badge if there are no mails.

Second issue (can't solve by myself)
If the number of incoming mails is greater than 9, the badge should stretch and reposition itself
with the number centered within it.

Third issue (can't solve by myself)
Same thing if the number of incoming mails is greater than 99.

Here the code:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Url=https://username:password@gmail.google.com/gmail/feed/atom
RegExp="(?siU)<fullcount>(.*)</fullcount>"
Codepage=0
DownloadLogo=1
FontName=Arial
IconSize=130
BadgeSize=( 4000 / #IconSize# )
FontSize=( ( #BadgeSize# * 37 ) / 100 )
White=255, 255, 255, 255


============
; Measures
;===========

[MeasureRSSNews]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#Url#
RegExp=#RegExp#
Codepage=#Codepage#
Download=#DownloadLogo#
UpdateRate=1
StringIndex=4
FinishAction=!Execute [!RainmeterRedraw]

[MeasureTitle]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureRSSNews]
StringIndex=1
UpdateRate=1
DynamicVariables=1
IfEqualValue=0
IfEqualAction=!execute [!RainmeterHideMeter [MeterTitle]][!RainmeterHideMeter [MeterBadge]]
IfAboveValue=0
IfBelowAction=!execute [!RainmeterShowMeter [MeterTitle]][!RainmeterShowMeter [MeterBadge]]

;=========
; Meters
;=========
[MeterIcon]
Meter=IMAGE
X=0
Y=0
W=#IconSize#
PreserveAspectRatio=1
ImageName=Icons\Mailbox.png
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]

[MeterBadge]
Meter=IMAGE
X=5
Y=20
W=#BadgeSize#
PreserveAspectRatio=1
ImageName=Icons\Badge1.png
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]

[MeterTitle]
Meter=STRING
MeasureName=MeasureTitle
X=14
Y=25
FontColor=#White#
StringStyle=BOLD
FontSize=#FontSize#
FontFace=#FontName#
AntiAlias=1
LeftMouseUpAction=!Execute ["http://mail.google.com/mail/"]
Sounds like it can be done without too much trouble using IfAboveAction and hiding / unhiding meters or even replacing images and setting variables like W, H, X and Y dynamically bases on the results of the measure returning "fullcount", but it would help if you could attach the images you want to use or do some kind of mock up in a paint program showing what you have in mind.
User avatar
kami
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Re: Using conditions in a 'Mail Checker' meter

Post by kami »

Actually i wanted to use ifabove ifbelow ifequal values and ifactions but altough i have read the official manual i ain't got it very well, i can't comprehend how these statements work.

P.S. i also can't understand correctly what you wrote about dynamic variables to set the positioning and 'redimensioning' parameters.

Could you please write some example code?
I would learn this!

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

Re: Using conditions in a 'Mail Checker' meter

Post by jsmorley »

kami wrote:Actually i wanted to use ifabove ifbelow ifequal values and ifactions but altough i have read the official manual i ain't got it very well, i can't comprehend how these statements work.

P.S. i also can't understand correctly what you wrote about dynamic variables to set the positioning and 'redimensioning' parameters.

Could you please write some example code?
I would learn this!

Thank you
Let me knock together something that demonstrates some of this. Give me 1/2 hour or so.
User avatar
kami
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Re: Using conditions in a 'Mail Checker' meter

Post by kami »

Of course! You're the best!
Thanks a lot :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using conditions in a 'Mail Checker' meter

Post by jsmorley »

Code: Select all

[Rainmeter]
Author=Jeffrey Morley
Update=1000

[Variables]
GMailID=xxxxxxx
GMailPassword=xxxxxx
StartBadgeWidth=20
BadgeWidth=20

;[GMAIL]===========================================

[MeasureMailCount]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=https://#GMailID#:#GMailPassword#@gmail.google.com/gmail/feed/atom
RegExp="(?siU)<fullcount>(.*)</fullcount>.*"
StringIndex=1
Substitute="":"0"
UpdateRate=600

[MeterGMail]
Meter=Image
ImageName=GMail.png
X=0
Y=5
W=50
PreserveAspectRatio=1
DynamicVariables=1
MiddleMouseUpAction=!RainmeterRefresh
LeftMouseUpAction=!Execute ["https://mail.google.com/mail/#inbox"][!RainmeterRefresh]

[MeterBadge]
Meter=Image
ImageName=CountBadge.png
W=#BadgeWidth#
H=20
X=36
Y=0
DynamicVariables=1
Hidden=1

[MeterCount]
Meter=String
MeasureName=MeasureMailCount
X=41
Y=2
FontSize=8
FontColor=255,255,255,255
StringStyle=Bold
DynamicVariables=1
Hidden=1

[MeasureCountSize]
Measure=Calc
Formula=MeasureMailCount < 10 ? #StartBadgeWidth# + 0 : (MeasureMailCount < 99 ? #StartBadgeWidth# + 5 : #StartBadgeWidth# + 10)

[MeasureDisplay]
Measure=Calc
Formula=MeasureMailCount
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterHideMeter MeterBadge][!RainmeterHideMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterBadge][!RainmeterShowMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
DynamicVariables=1
Here are the source images if you want to load my skin to see how it works:
GMail.png
CountBadge.png
And here is the result with less than 10 and more than 9 (the badge grows to fit the text)
1.png
2.png
Take a look at this. If you have questions about what it is doing (and I suspect you might) feel free to ask.
You do not have the required permissions to view the files attached to this post.
User avatar
kami
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Re: Using conditions in a 'Mail Checker' meter

Post by kami »

Thanks!
Now "0 inbox auto hiding" works but there are still problems with auto-positioning.

I followed your example but it doesn't work very well because when incoming mails number exceed the value 9, number is not in the correct position and this is not due to my eventual mistake in writing "offset" values but the whole formula (that one with condition) doesn't work.

I tried to write within the formula some values to see in which way the number shifted forward but nothing, it didn't work.

I saw that also in your example it didn't work.

Last time i had a problem it was because i had an old version of Rainmeter but now i have 1.2 and i don't think that this problem depends on which version i run.

I seized your example to make my code which is below
(i used a lot of calculations with variables so it will be possible resize all meters by editing less parameters)
it all works fine except for the problem i explained above.
Condition formula seems not to be operating.

Code: Select all

[Rainmeter]
Author=Jeffrey Morley
Update=1000

[Metadata]
Name=
Config=
Description=Google Mail Checker
Instructions=
Version=
Tags=Mail, Checker, GMail, Google, eMail, Mailbox
License=
Variant=
Preview=

[Variables]
GMailID=xxxxxxxx
GMailPassword=xxxxxxxx
IconWidth=128
BadgeSize=40
FontSize=( (#BadgeSize# * 37) / 100 )
White=255, 255, 255, 255
Black=0, 0, 0, 255
BadgePositionX=5
BadgePositionY=15
MeterCountX=( #BadgePositionX# - #FontSize# + (#BadgeSize# / 2) + ( ( #FontSize# * 8 )  / 100) )
MeterCountY=( #BadgePositionY# - #FontSize# + (#BadgeSize# / 2) + ( ( #FontSize# * 13 ) / 100) )

;[GMAIL]===========================================

[MeasureMailCount]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=https://#GMailID#:#GMailPassword#@gmail.google.com/gmail/feed/atom
RegExp="(?siU)<fullcount>(.*)</fullcount>.*"
StringIndex=1
Substitute="":"0"
UpdateRate=1

[MeterGMail]
Meter=Image
ImageName=Mailbox.png
X=0
Y=5
W=#IconWidth#
PreserveAspectRatio=1
DynamicVariables=1
MiddleMouseUpAction=!RainmeterRefresh
LeftMouseUpAction=!Execute ["https://mail.google.com/mail/#inbox"][!RainmeterRefresh]

[MeasureCountSize]
Measure=Calc
Formula=MeasureMailCount < 10 ? #MeterCountX# + 10 : (MeasureMailCount < 99 ? ( #MeterCountX# + (#Fontsize# / 2) ) : #MeterCountX# + 0)
DynamicVariables=1

[MeterBadge]
Meter=Image
W=#BadgeSize#
PreserveAspectRatio=1
X=#BadgePositionX#
Y=#BadgePositionY#
ImageName=Badge1.png
DynamicVariables=1
Hidden=1

[MeterCount]
Meter=String
MeasureName=MeasureMailCount
X=#MeterCountX#
Y=#MeterCountY#
FontName=Arial
FontSize=#FontSize#
FontColor=#White#
StringStyle=Bold
AntiAlias=1
DynamicVariables=1
Hidden=1

[MeasureDisplay]
Measure=Calc
Formula=MeasureMailCount
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterHideMeter MeterBadge][!RainmeterHideMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterBadge][!RainmeterShowMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
DynamicVariables=1
Badge1.png
Mailbox.png
Here it is the problem! This formula doesn't shift values
(i know i should care also about badge "auto-dimensioning" but now that issue is less important to me)

[MeasureCountSize]
Measure=Calc
Formula=MeasureMailCount < 10 ? #MeterCountX# + 10 : (MeasureMailCount < 99 ? ( #MeterCountX# + (#Fontsize# / 2) ) : #MeterCountX# + 0)
DynamicVariables=1


Now regardless of values i used in this formula, if i write this statement:
#MeterCountX# + 10
it should mean that the variable #MeterCountX# will be incremented of 10.
Therefore it should shift the position, but it doesn't do it!

Maybe i'm wrong or there's something i still don't know but where's the trouble!??
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using conditions in a 'Mail Checker' meter

Post by jsmorley »

You might try the 1.3 beta at http://rainmeter.net

I'm not sure offhand if that is the problem, but I think it is worth a try, as the skin I posted certainly works, as evidenced by the images I posted of it running.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using conditions in a 'Mail Checker' meter

Post by jsmorley »

I'm sorta confused as to what you are doing here...

This measure:

[MeasureDisplay]
Measure=Calc
Formula=MeasureMailCount
IfBelowValue=1
IfBelowAction=!Execute [!RainmeterHideMeter MeterBadge][!RainmeterHideMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
IfAboveValue=0
IfAboveAction=!Execute [!RainmeterShowMeter MeterBadge][!RainmeterShowMeter MeterCount][!RainmeterSetVariable BadgeWidth [MeasureCountSize]]
DynamicVariables=1

Is setting a variable BadgeWidth that is not initialized in [Variables], and in addition as far as I can see never used again, so what is the point?

This calc measure:

[MeasureCountSize]
Measure=Calc
Formula=MeasureMailCount < 10 ? #MeterCountX# + 10 : (MeasureMailCount < 99 ? ( #MeterCountX# + (#Fontsize# / 2) ) : #MeterCountX# + 0)
DynamicVariables=1

Seems to be working (it returns 21.4 when there are 1-9 emails, and 18.8 when there are 10)

But it is returning a value [MeasureCount] that you are then not using anywhere except in that calc statement above that sets a variable you never use.

There are several variables that are either not used or never changed from the initial values, I assume this is just stuff you plan to use later for purposes of changing the size / position of the badge, in addition to the count?

[MeterBadge]
Meter=Image
W=#BadgeSize# Set to 40 in Variables and then never changed
PreserveAspectRatio=1
X=#BadgePositionX#
Y=#BadgePositionY#
Set to 5 and 40 in Variables and then never changed
ImageName=Badge1.png
DynamicVariables=1
Hidden=1
User avatar
kami
Posts: 39
Joined: July 3rd, 2010, 10:47 am
Location: Canosa di Puglia, Italy

Re: Using conditions in a 'Mail Checker' meter

Post by kami »

I Fixed it!!! Thank you!

Now i want to extend this functionality to hotmail/msn/live mail monitoring.
I'll create another different post, i really don't know how to parse information from hotmail.