It is currently March 28th, 2024, 11:12 pm

[Solved] Why does this only work once...?

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

[Solved] Why does this only work once...?

Post by AzeTheGreat »

Alright, I'm trying to make something to easily hide the taskbar when I don't want it. If there are no windows open then it should be covered, but if there are windows open then it should stay up. I'm using an external program which returns 0 if there are no windows open and 1, 2, or 3 if there are windows, depending on their state. I'm only using 0 and not 0, nothing else matters right now. I'm using "leaving the taskbar" as the "refresh" state, since the alternative is updating constantly and using more resources than is ideal. The text meter is just there so I can see values, which was an attempt at troubleshooting that failed (the alphas being 150 instead of 1 is also for testing).

The problem: This only works once. If I open a window, then the taskbar stays up, no matter how much I move my cursor on and off of it. When I close all windows, move my cursor to the taskbar and then back up, it is properly hidden, and the text meter displays 0, like it should. However, if I then move my cursor back down, and then off of it, the taskbar stays up, when it should be hidden again. The text meter continues to display 0 the entire time, so I'm really confused as to why the first zero is different from each subsequent zero.

This pattern continues, every time I open and then close a program, it will correctly hide once after that.

Code: Select all

[Rainmeter]
Update = -1

[Variables]
TopAlpha = 0
BottomAlpha = 150
TaskbarAlpha = 255
WinChecking = 0

[measureCheckWindows]
Measure = Plugin
Plugin = RunCommand
Parameter = ""D:/Documents/request30.exe""
FinishAction = [!UpdateMeasure measureSelectWindow] [!UpdateMeter MeterResult] [!Redraw]
DynamicVariables = 1

[measureSelectWindow]
Measure = Calc
Formula = [measureCheckWindows]
DynamicVariables = 1
IfCondition = (measureSelectWindow = 0)
IfTrueAction = [!SetVariable TaskbarAlpha 255][!SetVariable TopAlpha 0][!SetVariable BottomAlpha 150] [!UpdateMeter meterTaskbar][!UpdateMeter meterTop][!UpdateMeter meterBottom][!Redraw]
IfFalseAction = [!SetVariable TopAlpha 0][!SetVariable BottomAlpha 150] [!UpdateMeter meterTop][!UpdateMeter meterBottom][!Redraw]

[MeterResult]
Meter=String
MeasureName = measureCheckWindows
MeasureName2 = measureSelectWindow
Text = %1, %2
X = 0
Y = 0
FontSize=40
FontColor=255,255,255,255
AntiAlias=1

[meterTop]
Meter = Image
W = 1920
H = 1050
SolidColor = 0,0,0,#TopAlpha#
DynamicVariables = 1
MouseOverAction = [!SetVariable TopAlpha 0][!SetVariable BottomAlpha 150] [!CommandMeasure measureCheckWindows "Run"] [!UpdateMeter meterTop][!UpdateMeter meterBottom][!Redraw]

[meterBottom]
Meter = Image
W = 1920
H = 30
Y = 1050
SolidColor = 0,0,0,#BottomAlpha#
DynamicVariables = 1
MouseOverAction = [!SetVariable TopAlpha 150][!SetVariable BottomAlpha 0][!SetVariable TaskbarAlpha 0] [!UpdateMeter meterTop][!UpdateMeter meterBottom][!UpdateMeter meterTaskbar][!Redraw]

[meterTaskbar]
Meter = Image
ImageName = #@#Taskbar.png
Y = 1050
ImageAlpha = #TaskbarAlpha#
DynamicVariables = 1
Edit: After doing some more troubleshooting I think I've narrowed it down to it somehow needing a change to zero to properly work. If I open a window and close it from the taskbar (so that it never gets a value of one) it's not covered up. This is consistent with it only covering once after a program is open, because every other time there's no change, it's just constant at zero. I just can't figure out why it would need a change...

Edit 2: I just found IfConditionMode and I think if I set that to 1 it should fix my problem. I'll mark this as solved if it does.

Edit 3: Yup, that fixed it.
Last edited by AzeTheGreat on January 17th, 2017, 10:39 pm, edited 3 times in total.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Why does this only work once...?

Post by fonpaolo »

Using Update=-1 means that you only update this skin when is loaded or when you use a !Refresh bang.

If it has to monitor the windows, you can use Update=1000 (or once a second) or also Update=2000, the delay is not really noticeable.
AzeTheGreat
Posts: 16
Joined: January 13th, 2017, 1:08 am

Re: Why does this only work once...?

Post by AzeTheGreat »

fonpaolo wrote:Using Update=-1 means that you only update this skin when is loaded or when you use a !Refresh bang.

If it has to monitor the windows, you can use Update=1000 (or once a second) or also Update=2000, the delay is not really noticeable.
I know the skin itself won't refresh, which is why I'm using various !Update bangs. The difference between having the skin on a 1s refresh and manually updated is actually very noticeable (to me at least). Also, setting it to Update=1000 doesn't fix the issue.

After doing some more troubleshooting I think I've narrowed it down to it somehow needing a change to zero to properly work. If I open a window and close it from the taskbar (so that it never gets a value of one) it's not covered up. This is consistent with it only covering once after a program is open, because every other time there's no change, it's just constant at zero. I just can't figure out why it would need a change...
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Why does this only work once...?

Post by balala »

fonpaolo wrote:Using Update=-1 means that you only update this skin when is loaded or when you use a !Refresh bang.
I'm sorry fonpaolo, I have to argue again. Updating and refreshing a skin are completely different things, don't confuse them. When a !Refresh bang is used, the skin is not updated, but refreshed. This should be treated with care: https://forum.rainmeter.net/viewtopic.php?p=119966#p119966
If the skin is set to Update=-1, it can be updated using the !Update bang, but many times this again isn't the best approach: better would be to update just the right sections, using the appropriate !UpdateMeasure / !UpdateMeasureGroup respectively !UpdateMeter / !UpdateMeterGroup bangs.
As jsmorley said, the !Refresh usually should be avoided.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: Why does this only work once...?

Post by fonpaolo »

Thanks balala for the clarification, I only used a reference from the Docs: "Using -1 will update the skin only once on load (or on refresh)", just ommitted the other part "The skin can then be manually updated using the !Update bang."