It is currently April 18th, 2024, 6:25 am

[Solved] Everything works, except for !Update...

Get help with creating, editing & fixing problems with skins
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

[Solved] Everything works, except for !Update...

Post by AzeTheGreat »

I'm working on a tool to notify me of when I have a new reddit message, everything works except this last little bit. If I just leave it alone, it turns on when I have a message, and turns off once I view it. The problem is, these events happen on a rather slow refresh cycle, so I was hoping I could make it more instantaneous by forcing it to update when I clicked on it (so when I go to my unread messages, it updates, sees I've now read them, and turns off). !Update supposedly doesn't override UpdateRate, so I used !UpdateMeasure for one measure, !Update to do everything else, and finished with !Redraw. However when I click, it behaves exactly the same as if I didn't have them.

Code:

Code: Select all

[Rainmeter]
Update = 60

[Variables]
USERNAME = AzeTheGreat
HASH = ****************************************

[measureMail]
Measure = Plugin
Plugin = WebParser
RegExp = (?siU)has_mail": (.*),
Url = "http://www.reddit.com/user/#USERNAME#/about.json?feed=#HASH#&user=#USERNAME#&mark=false"
UpdateRate = 1000
StringIndex = 1
Substitute = "true":"1","false":"0"

[measureSelectWindow]
Measure = Calc
Formula = [measureMail]
IfEqualValue = 1
IfAboveAction = [!ShowMeter meterWindowOn] [!HideMeter meterWindowOff]
IfBelowValue = 1
IfBelowAction = [!ShowMeter meterWindowOff] [!HideMeter meterWindowOn]
DynamicVariables = 1


[meterWindowOn]
Meter = Image
LeftMouseUpAction = !Execute ["http://www.reddit.com/message/unread/"] [!UpdateMeasure measureMail] [!Update] [!Redraw]
ImageName = #@#WindowOn.png
Hidden = 1

[meterWindowOff]
Meter = Image
LeftMouseUpAction = [!UpdateMeasure measureMail] [!Update] [!Redraw]
ImageName = #@#WindowOff.png
Hidden = 1
Last edited by AzeTheGreat on January 17th, 2017, 5:59 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Everything works, except for !Update...

Post by balala »

A WebParser measure (or a WebParser plugin measure) must be updated with the !CommandMeasure bang, not with !UpdateMeasure (read the last paragraph here). So, replace the LeftMouseUpAction option of the [meterWindowOff] meter with the following one: LeftMouseUpAction = [!CommandMeasure "measureMail" "Update"][!Update][!Redraw]. I also would remove the [!Update] and the [!Redraw] bangs, because a WebParser measure needs time to be updated, but at the end of each cycle, the whole skin is updated and redrawn, so finally these bangs seem useless.
Also two comments about the posted code:
  • Update = 60 (in [Rainmeter] section)? Are you sure a such small value is needed? I don't think so. Plus in such cases you should be careful, because the skin will connect and download the data on each 0.06 (the Update value of the skin) x 1000 (the UpdateRate of the measure) = 60 secs (once per minute). Maybe that's too often. At least on the posted piece of code is nothing which would require it. I don't know if this is the whole code, but if it is, I'd suggest to replace this with the default Update=1000. It's completely enough.
  • The !Execute bang is deprecated (you've used it in the LeftMouseUpAction option of the [meterWindowOn] meter). You should remove it.
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

Re: Everything works, except for !Update...

Post by AzeTheGreat »

My god, you're amazing! Seriously, I've noticed you replying everywhere, and now you reply with the exact solution to my issue. Thank you so much. The only issue I have now is that clicking on the icon when I have notifications doesn't immediately update it (I assume due to the delay accessing the internet) but the second click does. I've got a couple ideas to fix that though.

The only other thing I'd ask is: I have another skin that launches steam. Currently my update rate is 25. You seemed to think that 60 was too fast of an update...so I feel like the fact that this one is 25 wouldn't be great...I have the update rate set that low so that the fade in/out looks nice...should I implement some kind of dynamic update rate so it's less cpu intensive? If so, do you have any suggestions? I can provide my code if needed.
User avatar
sephirotess
Posts: 332
Joined: December 8th, 2016, 6:45 am

Re: Everything works, except for !Update...

Post by sephirotess »

AzeTheGreat wrote: The only other thing I'd ask is: I have another skin that launches steam. Currently my update rate is 25. You seemed to think that 60 was too fast of an update...so I feel like the fact that this one is 25 wouldn't be great...I have the update rate set that low so that the fade in/out looks nice...should I implement some kind of dynamic update rate so it's less cpu intensive? If so, do you have any suggestions? I can provide my code if needed.

Hello,

You do not need a low update to run an application. I would even say that you do not need an update in this case. If it is simply an icon to launch an application, then choose "Update = -1".
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Everything works, except for !Update...

Post by balala »

AzeTheGreat wrote:My god, you're amazing! Seriously, I've noticed you replying everywhere, and now you reply with the exact solution to my issue. Thank you so much. The only issue I have now is that clicking on the icon when I have notifications doesn't immediately update it (I assume due to the delay accessing the internet) but the second click does. I've got a couple ideas to fix that though.
Glad to help.
About the update delay, take into account that a WebParser (plugin) measure needs time to be updated, because it has to connect the proper site and download the data. Usually this can take a few seconds.
AzeTheGreat wrote:The only other thing I'd ask is: I have another skin that launches steam. Currently my update rate is 25. You seemed to think that 60 was too fast of an update...so I feel like the fact that this one is 25 wouldn't be great...I have the update rate set that low so that the fade in/out looks nice...should I implement some kind of dynamic update rate so it's less cpu intensive? If so, do you have any suggestions? I can provide my code if needed.
You can't change the value of the Update option (within the [Rainmeter] section), neither with the !SetOption, neither with !SetVariable, because dynamic variables can't be used in the [Rainmeter] section. So, you can't implement, as you said, a "dynamic update rate". I'm not sure what kind of fade in/out are you using, but I don't think a such small Update would be required. If you're talking about the !ShowFade / !HideFade / !ToggleFade bangs, there's no important at all the Update value, the effect will work same way. On the other hand if you're using some other method, probably neither that is not requiring small update values, because you can use the ActionTimer plugin, which can help very much in such cases. Maybe even sephirotess's suggestion could be a good one. It depends...
All in all, please post the incriminated code, to can take a look.
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

Re: Everything works, except for !Update...

Post by AzeTheGreat »

balala wrote:Glad to help.
About the update delay, take into account that a WebParser (plugin) measure needs time to be updated, because it has to connect the proper site and download the data. Usually this can take a few seconds.
Yeah I ended up just forcing the icon to go back to the off state instead of having it actually check the webpage again, since that's what should happen anyways.
balala wrote:You can't change the value of the Update option (within the [Rainmeter] section), neither with the !SetOption, neither with !SetVariable, because dynamic variables can't be used in the [Rainmeter] section. So, you can't implement, as you said, a "dynamic update rate". I'm not sure what kind of fade in/out are you using, but I don't think a such small Update would be required. If you're talking about the !ShowFade / !HideFade / !ToggleFade bangs, there's no important at all the Update value, the effect will work same way. On the other hand if you're using some other method, probably neither that is not requiring small update values, because you can use the ActionTimer plugin, which can help very much in such cases. Maybe even sephirotess's suggestion could be a good one. It depends...
All in all, please post the incriminated code, to can take a look.
I didn't even know about the Fade bangs...I'll take a look at the ActionTimer plugin, it sounds promising.

Here's my current code:

Code: Select all

[Rainmeter]
Update = 25

[Variables]
InstallPath = D:\Steam\Steam.exe
Fade = 0
FadeInc = 15
Fmax = 255
Fmin = 0

[FadeControl]
DynamicVariables = 1
Measure = Calc
Formula = #Fade#=1 ? ( FadeControl>(#Fmax#-#FadeInc#)?(#Fmax#):(FadeControl+#FadeInc#) ) : ( FadeControl<(#Fmin#+#FadeInc#)?(#Fmin#):(FadeControl-#FadeInc#) )

[meterButton]
Meter = Image
ImageName = #@#SimpleSteamButton.png
ImageAlpha = 1
MouseOverAction = !SetVariable Fade 1
MouseLeaveAction = !SetVariable Fade 0
LeftMouseUpAction = ["#InstallPath#"]

[meterIcon]
Meter = Image
ImageName = #@#SimpleSteam32.png
ImageAlpha = [FadeControl]
DynamicVariables = 1
X = 4
Y = 4
Edit: Does MouseOverAction continually activate as long as the mouse is over, or only once when it's moved over? I'm struggling to figure out how I could optimize this without losing functionality...
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Everything works, except for !Update...

Post by balala »

AzeTheGreat wrote:I'll take a look at the ActionTimer plugin, it sounds promising.
The ActionTimer plugin can be extremely useful in such cases. Eg instead of a such low Update value of your last code (25), which always is an undesirable value, you even can modify this to -1 (Update=-1). Update=-1 means that the skin automatically is never updated, to update it you have to use an !Update bang, or have to update the measures / meters one by one (or by group).
Now in this case, the skin as you had it, won't work, because if it's never updated, even if you're hovering the mouse over it, the image won't be shown.
But, you can add the following measure:

Code: Select all

[MeasureSlide]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat FadeIn,10,25
FadeIn=[!SetVariable Alpha "(Clamp(#Alpha#+10,0,255))"]#U#
ActionList2=Repeat FadeOut,10,25
FadeOut=[!SetVariable Alpha "(Clamp(#Alpha#-10,0,255))"]#U#
DynamicVariables=1
This measure will update the value of the Alpha variable on each 10 milliseconds (the first number in the ActionList1 and ActionList2 options), 25 times (the second number). On each such update, the ActionList1 option will add 10 to the actual value of the variable, while ActionList2 will extract 10. The first one will be used when you're hovering the mouse over the appropriate meter, the second one, when you're leaving the meter (image).
Now you have to initialize the Alpha variable. Add to the [Variables] section the following variables (we also will need the U variable, add it now):

Code: Select all

[Variables]
LEAVE THE OTHER VARIABLES UNTOUCHED
Alpha=0
U=[!UpdateMeasure "MeasureSlide"][!UpdateMeter "meterIcon"][!Redraw]
You don't need any more the [FadeControl] measure, you can completely remove it.
Replace the MouseOverAction and MouseLeaveAction options of the [meterButton] meter as it follows:

Code: Select all

[meterButton]
Meter=Image
...
MouseOverAction=[!CommandMeasure MeasureSlide "Stop 2"][!CommandMeasure MeasureSlide "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureSlide "Stop 1"][!CommandMeasure MeasureSlide "Execute 2"]
These options mean that when you're hovering the mouse over the [meterButton] meter, the ActionList1 option of the [MeasureSlide] measure will start to execute and ActionList2 will be blocked, when you're leaving the meter, exactly vice-versa will happen.
You have to do just one single thing: replace the ImageAlpha option of the [meterIcon] meter with the following one: ImageAlpha=#Alpha#.
That's it. Now even if you have the Update value set to -1, or to the default 1000, the fade effect still will work, without having to use a too small Update value. And that's a very good step, the low update values should be avoided as much as it is possible.
AzeTheGreat wrote:Edit: Does MouseOverAction continually activate as long as the mouse is over, or only once when it's moved over? I'm struggling to figure out how I could optimize this without losing functionality...
As every other in the ini files approach, only once. To activate it again, something have to change. Eg you have to leave first the meter, then hover the mouse again over it.
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

Re: Everything works, except for !Update...

Post by AzeTheGreat »

balala wrote: That's it. Now even if you have the Update value set to -1, or to the default 1000, the fade effect still will work, without having to use a too small Update value. And that's a very good step, the low update values should be avoided as much as it is possible.

As every other in the ini files approach, only once. To activate it again, something have to change. Eg you have to leave first the meter, then hover the mouse again over it.
Cool, I'll look into that!

Now...unfortunately...I've noticed another problem with my original code. For some reason my "refresh" click stops working if I click on the window to open reddit.

Code:

Code: Select all

[Rainmeter]
Update = 60

[Variables]
USERNAME = AzeTheGreat
HASH = ****************************************

[measureMail]
Measure = Plugin
Plugin = WebParser
RegExp = (?siU)has_mail": (.*),
Url = "http://www.reddit.com/user/#USERNAME#/about.json?feed=#HASH#&user=#USERNAME#&mark=false"
UpdateRate = 1000
StringIndex = 1
Substitute = "true":"1","false":"0"

[measureSelectWindow]
Measure = Calc
Formula = [measureMail]
IfEqualValue = 1
IfAboveAction = [!ShowMeter meterWindowOn] [!HideMeter meterWindowOff]
IfBelowValue = 1
IfBelowAction = [!ShowMeter meterWindowOff] [!HideMeter meterWindowOn]
DynamicVariables = 1


[meterWindowOn]
Meter = Image
LeftMouseUpAction = ["http://www.reddit.com/message/unread/"] [!ShowMeter meterWindowOff] [!HideMeter meterWindowOn]
ImageName = #@#WindowOn.png
Hidden = 1

[meterWindowOff]
Meter = Image
LeftMouseUpAction = [!CommandMeasure "measureMail" "Update"] 
ImageName = #@#WindowOff.png
Hidden = 1
I'm assuming this is some issue with me setting the meters when I click, but I can't figure out why that'd be an issue.
User avatar
balala
Rainmeter Sage
Posts: 16143
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Everything works, except for !Update...

Post by balala »

AzeTheGreat wrote:For some reason my "refresh" click stops working if I click on the window to open reddit.
I'm not sure I understood what you mean by "refresh" click.
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

Re: Everything works, except for !Update...

Post by AzeTheGreat »

balala wrote:I'm not sure I understood what you mean by "refresh" click.
On the [meterWindowOff] meter I have a leftMouseUpAction that should update the measureMail portion. The idea is I can click it to instantly update, which will be nice when I'm done testing and the update interval is much longer. That's the refresh click. This functions, however it stops working after I click of the [meterWindowOn] meter, I assume because I then force change the meters. I'm not sure why this would affect it though...