diff --git a/Library/Measure.cpp b/Library/Measure.cpp index fbe9caf6..c6eaebe2 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -86,7 +86,9 @@ CMeasure::CMeasure(CMeterWindow* meterWindow, const WCHAR* name) : CSection(name m_IfAboveCommitted(false), m_IfBelowCommitted(false), m_Disabled(false), - m_Initialized(false) + m_Initialized(false), + m_OldValue(0.0), + m_OldStringValue(L"") { } @@ -145,6 +147,7 @@ void CMeasure::ReadOptions(CConfigParser& parser, const WCHAR* section) m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false); m_OnUpdateAction = parser.ReadString(section, L"OnUpdateAction", L"", false); + m_OnChangeAction = parser.ReadString(section, L"OnChangeAction", L"", false); m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0); diff --git a/Library/Measure.h b/Library/Measure.h index ca2cedbe..db9134ce 100644 --- a/Library/Measure.h +++ b/Library/Measure.h @@ -69,6 +69,12 @@ public: std::wstring GetOnUpdateAction() { return m_OnUpdateAction; } + std::wstring GetOnChangeAction() { return m_OnChangeAction; } + void SetOldValue(double value) { m_OldValue = value; } + double GetOldValue() { return m_OldValue; } + void SetOldStringValue(std::wstring value) { m_OldStringValue = value; } + std::wstring GetOldStringValue() { return m_OldStringValue; } + CMeterWindow* GetMeterWindow() { return m_MeterWindow; } static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow, const WCHAR* name); @@ -114,6 +120,10 @@ protected: std::wstring m_OnUpdateAction; + std::wstring m_OnChangeAction; + double m_OldValue; + std::wstring m_OldStringValue; + CMeterWindow* m_MeterWindow; }; diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index a2549e27..24484a0f 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2689,6 +2689,17 @@ void CMeterWindow::Update(bool refresh) { Rainmeter->ExecuteCommand(updateAction.c_str(), this); } + + double newValue = (*i)->GetValue(); + const WCHAR* newStringValue = (*i)->GetStringValue(AUTOSCALE_OFF, 1, -1, false); + std::wstring changeAction = (*i)->GetOnChangeAction(); + + if (((*i)->GetOldValue() != newValue || (*i)->GetOldStringValue() != newStringValue) && !changeAction.empty()) + { + (*i)->SetOldValue(newValue); + (*i)->SetOldStringValue(newStringValue); + Rainmeter->ExecuteCommand(changeAction.c_str(), this); + } } } }