Thank you all for your kindness. I've been on many coding forums in the past most ranging from condescending to dismissive. There is a very welcoming supportive community vibe here of which I am appreciative.
I gained a lot of understanding in the examples provided. The 'Disabled' command alone made me very happy as that was a problem fixed for part I haven't written yet.
That said, I'd like to be lazy now. I'm tired of staring at this problem and would like to just post the whole code and have you show me what I am doing wrong. I'm not asking to have the whole thing transformed. There is much wrong, much not finished and much more that can be streamlined and improved. But I look forward to doing all that myself.
I just want this one little part to work. I think at this point I can learn more from the correction than by fighting (randomly making changes) for it.
When I run it, it shows the Ext IP and after 5 seconds the Location. So the location display code (very bottom of the skin) still works. If the IP changes, less than 90 seconds later the IP display updates.
But the location display does not. I can see your part work but the part I had to add clearly does not.
I took the timer off the location so that it would only be called when needed. That is probably where I messed up but I can't see it.
Again, please resist the urge to tidy and improve. I'd appreciate as little as humanly possible be changed to make the location measure update when the ip changes. I look forward to fixing the rest as I learn.
Code: Select all
[Rainmeter]
Update=1000
AccurateText=1
[Metadata]
Name=Traffic
Author=Codger
Information=My second widget
Version=0.1.2
License=Free to all to do with as they like
; Notes: This widget makes use of three websites:
;
; http://www.Bing.com is called every 3 seconds to test Ping.
; http://icanhazip.com is called every 90 seconds to determine External IP
; http://ipinfo.io/ is called every 20 minutes to determine location
; (eventually this will be tried to change in External IP)
;
[Variables]
; Static Variables
BackPadding=15
BarWidth=330
;tied to PingBar.png
PureBlue=0,0,255
PureRed=255,0,0
PureGreen=0,255,0
PureYellow=255,255,0
PureWhite=255,255,255
BurntOrange=153,76,0
MediumOrange=255,128,0
RedOrange=255,51,51
DarkGreen=0,102,0
BarBackColor=60,60,60,200
BarTextColor=#PureWhite#,255
DownloadColor=#DarkGreen#,255
UploadColor=#BurntOrange#,255
OverloadColor=#PureRed#,255
PingColor=#PureBlue#,255
PingHighColor=#RedOrange#,255
PingOverloadColor=#PureRed#,255
OfflineColor=255,0,0,255
PingSite="www.bing.com"
HighestLikelyTraffic=2750000
HighestPing=300
IPlast=196.52.48.67
[Background]
Meter=Image
W=(#BarWidth# + (#BackPadding#*2))
H=216
SolidColor=30,30,30,200
BevelType=1
UpdateDivider=-1
;
; PIA Status
; Just displays a logo at the moment.
;Future spot for PIA and LeapIP status indication
;
[PIAStatus]
Meter=Image
ImageName=@Resources\PIAGreen.png
W=32
H=32
Y=5r
X=(((#BarWidth#/2) + #BackPadding#/2)-8)
;
; Ext IP
[MeasureExtIP]
Measure=Plugin
Plugin=WebParser
Url=http://icanhazip.com
RegExp="(?siU)^(.*)$"
StringIndex=1
UpdateRate=90
FinishAction=[!EnableMeasure MeasureCheck][!UpdateMeasure MeasureCheck]
[MeasureCheck]
Measure=Plugin
Plugin=WebParser
Url=[MeasureExtIP]
StringIndex=1
IfMatch=#IPLast#
IfNotMatchAction=[!SetVariable IPLast "[MeasureCheck]"][!WriteKeyValue Variables IPLast "[MeasureCheck]"][!UpdateMeasure "MeasureWebParseLocation"]
IfMatchMode=1
DynamicVariables=1
Disabled=1
[MeterExtIP]
Meter=String
MeasureName=MeasureExtIP
X=#BackPadding#
Y=15r
FontSize=10
StringStyle=Bold
FontColor=#PureYellow#,255
Text="Ext IP: %1"
;
; Online
[Internet]
Measure=Plugin
Plugin=SysInfo
SysInfoType=INTERNET_CONNECTIVITY
SysInfoData=Best
UpdateDivider=-1
[InternetStatus]
Measure=String
String=Status: [Internet]
Substitute="-1":"Offline", "1":"Online"
DynamicVariables=1
UpdateDivider=1
[MeterInternetStatus]
Meter=String
MeasureName=InternetStatus
X=(#BarWidth#+#BackPadding#)
Y=r
FontSize=10
StringStyle=Bold
StringAlign=Right
FontColor=150,150,150,255
InlineSetting=Color | #OfflineColor#
InlinePattern=Offline
DynamicVariables=1
;!Redraw
; 1st
; Ping
[MeasurePing]
Measure=Plugin
Plugin=PingPlugin
DestAddress=#PingSite#
Timeout=3000
UpdateRate=3
FinishAction=[!UpdateMeter "MeterPingBar"][!UpdateMeter "MeterPing"]
TimeoutAction=[!UpdateMeter "MeterPingBar"][!UpdateMeter "MeterPing"]
[BoundPing]
Measure=Calc
MinValue=0
MaxValue=#HighestPing#
Formula=MeasurePing
;IfEqualValue=30000
;IfEqualAction=
; Internet Offline ^
[FormatPing]
Measure=String
MeasureName=Internet
Substitute "-1" : "Offline", "1" : "Ping: %1ms"
[MeterPingBar]
Meter=BAR
MeasureName=BoundPing
X=#BackPadding#
Y=20r
W=#BarWidth#
H=21
; if H is changed dimensions of PingBar.png must changed as well.
;BarColor=#PingColor#
SolidColor=#BarBackColor#
BarImage=@Resources\PingBar.png
BarOrientation=Horizontal
BevelType=1
UpdateDivider=-1
[MeterPing]
Meter=String
MeasureName=BoundPing
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
Text = "Ping: %1ms"
UpdateDivider=-1
; 2nd
; Current Upload Traffic
[MeasureUploadTraffic]
Measure=NetOut
Interface=Best
AutoScale=2
[BoundUploadTraffic]
Measure=Calc
MinValue=0
MaxValue=#HighestLikelyTraffic#
Formula=MeasureUploadTraffic
[MeterUploadBar]
Meter=BAR
MeasureName=BoundUploadTraffic
X=-4r
Y=25r
W=#BarWidth#
H=21
MinValue=0
MaxValue=#HighestLikelyTraffic#
BarColor=#UploadColor#
SolidColor=#BarBackColor#
BarOrientation=Horizontal
BevelType=1
[MeterUploadText]
Meter=String
MeasureName=MeasureUploadTraffic
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
AutoScale=1
NumOfDecimals=1
Text="Upload: %1"
; 3rd
; Current Download Traffic
[MeasureDownloadTraffic]
Measure=NetIn
Interface=Best
AutoScale=2
[BoundDownloadTraffic]
Measure=Calc
MinValue=0
MaxValue=#HighestLikelyTraffic#
Formula=MeasureDownloadTraffic
Percentual=1
[MeterDownloadBar]
Meter=BAR
MeasureName=BoundDownloadTraffic
X=-4r
Y=25r
W=#BarWidth#
H=21
MinValue=0
MaxValue=#HighestLikelyTraffic#
BarColor=#DownloadColor#
SolidColor=#BarBackColor#
BarOrientation=Horizontal
BevelType=1
[MeterDownloadText]
Meter=String
MeasureName=MeasureDownloadTraffic
X=4r
Y=3r
FontSize=10
StringStyle=Bold
FontColor=#BarTextColor#
AutoScale=1
NumOfDecimals=1
Text="Download: %1"
;
; Network Traffic Histograph
[MeterUploadHistogram]
Meter=Histogram
MeasureName=BoundUploadTraffic
Flip=1
X=-4r
Y=59r
W=#BarWidth#
H=30
PrimaryColor=#UploadColor#
SolidColor=#BarBackColor#
BevelType=1
AntiAlias=1
[MeterDownloadHistogram]
Meter=Histogram
MeasureName=BoundDownloadTraffic
X=r
Y=-34r
W=#BarWidth#
H=32
PrimaryColor=#DownloadColor#
SolidColor=#BarBackColor#
BevelType=1
AntiAlias=1
; Location
;
[MeasureWebParseLocation]
Measure=Plugin
Plugin=WebParser
URL=http://ipinfo.io/
RegExp=(?siU)<a class="flag .*</a>\n(.*)</td>
UpdateDivider=-1
[MeasureLocation]
Measure=Plugin
Plugin=WebParser
URL=[MeasureWebParseLocation]
StringIndex=1
DecodeCharacterReference=1
RegExpSubstitute=1
Substitute="^\s+":"","<!\[CDATA\[":"","\]\]>":"","!\[CDATA\[":"","\]\]":""
[MeterLocation]
Meter=String
MeasureName=MeasureLocation
X=2r
Y=69r
FontSize=11
StringStyle=Bold
FontColor=#PureYellow#,255
Text="@ %1"
DynamicVariables=1
UpdateDivider=5
;[Initialize]
;!UpdateMeasure "MeasurePing"
;!UpdateMeter "MeterExtIP"
;UpdateDivider=-1
However if you want to show me how to merge [MeasureWebParseLocation] and [MeasureLocation] into the one measure I think they want to be I would be happy as I am completely lost how the second one strips off leading spaces and tabs. If not the other is all that is really important at this juncture.
Oh, one thing confuses me on the previous example.
If IfMatch works in a RegExp manner, why do the periods in the IP address not mess things up? What makes it literal?
Please let me know if I become annoying.