Skip to content

Commit a97bba0

Browse files
committed
Updated Initial Version
1 parent ff0b5cd commit a97bba0

File tree

9 files changed

+1561
-2
lines changed

9 files changed

+1561
-2
lines changed

API/DllExporter.exe

8.5 KB
Binary file not shown.

API/RainmeterAPI.cs

Lines changed: 450 additions & 0 deletions
Large diffs are not rendered by default.

API/RainmeterAPI.h

Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
/* Copyright (C) 2011 Rainmeter Project Developers
2+
*
3+
* This Source Code Form is subject to the terms of the GNU General Public
4+
* License; either version 2 of the License, or (at your option) any later
5+
* version. If a copy of the GPL was not distributed with this file, You can
6+
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
7+
8+
#ifndef __RAINMETERAPI_H__
9+
#define __RAINMETERAPI_H__
10+
11+
#ifdef LIBRARY_EXPORTS
12+
#define LIBRARY_EXPORT EXTERN_C
13+
#else
14+
#define LIBRARY_EXPORT EXTERN_C __declspec(dllimport)
15+
#endif // LIBRARY_EXPORTS
16+
17+
#define PLUGIN_EXPORT EXTERN_C __declspec(dllexport)
18+
19+
//
20+
// Exported functions
21+
//
22+
23+
/// <summary>
24+
/// Retrieves the option defined in the skin file
25+
/// </summary>
26+
/// <param name="rm">Pointer to the plugin measure</param>
27+
/// <param name="option">Option name to be read from skin</param>
28+
/// <param name="defValue">Default value for the option if it is not found or invalid</param>
29+
/// <param name="replaceMeasures">If true, replaces section variables in the returned string</param>
30+
/// <returns>Returns the option value as a string (LPCWSTR)</returns>
31+
/// <example>
32+
/// <code>
33+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
34+
/// {
35+
/// LPCWSTR value = RmReadString(rm, L"Value", L"DefaultValue");
36+
/// LPCWSTR action = RmReadString(rm, L"Action", L"", FALSE); // [MeasureNames] will be parsed/replaced when the action is executed with RmExecute
37+
/// }
38+
/// </code>
39+
/// </example>
40+
#ifdef __cplusplus
41+
LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE);
42+
#else
43+
LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures);
44+
#endif // __cplusplus
45+
46+
/// <summary>
47+
/// Parses any formulas in the option (use RmReadDouble/RmReadInt instead)
48+
/// </summary>
49+
/// <param name="rm">Pointer to the plugin measure</param>
50+
/// <param name="option">Option name to be read from skin</param>
51+
/// <param name="defValue">Default value for the option if it is not found, invalid, or a formula could not be parsed</param>
52+
/// <returns>Returns the option value as an double</returns>
53+
/// <example>
54+
/// <code>
55+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
56+
/// {
57+
/// double value = RmReadFormula(rm, L"Value", 20);
58+
/// }
59+
/// </code>
60+
/// </example>
61+
LIBRARY_EXPORT double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue);
62+
63+
/// <summary>
64+
/// Returns a string, replacing any variables (or section variables) within the inputted string
65+
/// </summary>
66+
/// <param name="rm">Pointer to the plugin measure</param>
67+
/// <param name="str">String with unresolved variables</param>
68+
/// <returns>Returns a string replacing any variables in the 'str'</returns>
69+
/// <example>
70+
/// <code>
71+
/// PLUGIN_EXPORT double Update(void* data)
72+
/// {
73+
/// Measure* measure = (Measure*)data;
74+
/// LPCWSTR myVar = RmReplaceVariables(measure->rm, L"#MyVar#"); // 'measure->rm' stored previously in the Initialize function
75+
/// if (_wcsicmp(myVar, L"SOMETHING") == 0) { return 1.0; }
76+
/// return 0.0;
77+
/// }
78+
/// </code>
79+
/// </example>
80+
LIBRARY_EXPORT LPCWSTR __stdcall RmReplaceVariables(void* rm, LPCWSTR str);
81+
82+
/// <summary>
83+
/// Converts a relative path to a absolute path (use RmReadPath where appropriate)
84+
/// </summary>
85+
/// <param name="rm">Pointer to the plugin measure</param>
86+
/// <param name="relativePath">String of path to be converted</param>
87+
/// <returns>Returns the absolute path of the relativePath value as a string (LPCWSTR)</returns>
88+
/// <example>
89+
/// <code>
90+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
91+
/// {
92+
/// std::wstring somePath = L"..\\SomeFolder";
93+
/// LPCWSTR path = RmPathToAbsolute(rm, somePath.c_str());
94+
/// }
95+
/// </code>
96+
/// </example>
97+
LIBRARY_EXPORT LPCWSTR __stdcall RmPathToAbsolute(void* rm, LPCWSTR relativePath);
98+
99+
/// <summary>
100+
/// Executes a command
101+
/// </summary>
102+
/// <param name="skin">Pointer to current skin (See RmGetSkin)</param>
103+
/// <param name="command">Bang to execute</param>
104+
/// <returns>No return type</returns>
105+
/// <example>
106+
/// <code>
107+
/// PLUGIN_EXPORT double Update(void* data)
108+
/// {
109+
/// Measure* measure = (Measure*)data;
110+
/// RmExecute(measure->skin, L"!SetVariable SomeVar 10"); // 'measure->skin' stored previously in the Initialize function
111+
/// return 0.0;
112+
/// }
113+
/// </code>
114+
/// </example>
115+
LIBRARY_EXPORT void __stdcall RmExecute(void* skin, LPCWSTR command);
116+
117+
/// <summary>
118+
/// Retrieves data from the measure or skin (use the helper functions instead)
119+
/// </summary>
120+
/// <remarks>Call RmGet() in the Initialize function and store the results for later use</remarks>
121+
/// <param name="rm">Pointer to the plugin measure</param>
122+
/// <param name="type">Type of information to retrieve (see RmGetType)</param>
123+
/// <returns>Returns a pointer to an object which is determined by the 'type'</returns>
124+
/// <example>
125+
/// <code>
126+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
127+
/// {
128+
/// Measure* measure = new Measure;
129+
/// *data = measure;
130+
/// measure->hwnd = RmGet(rm, RMG_SKINWINDOWHANDLE); // 'measure->hwnd' defined as HWND in class scope
131+
/// }
132+
/// </code>
133+
/// </example>
134+
LIBRARY_EXPORT void* __stdcall RmGet(void* rm, int type);
135+
136+
enum RmGetType
137+
{
138+
RMG_MEASURENAME = 0,
139+
RMG_SKIN = 1,
140+
RMG_SETTINGSFILE = 2,
141+
RMG_SKINNAME = 3,
142+
RMG_SKINWINDOWHANDLE = 4
143+
};
144+
145+
/// <summary>
146+
/// Sends a message to the Rainmeter log with source
147+
/// </summary>
148+
/// <remarks>LOG_DEBUG messages are logged only when Rainmeter is in debug mode</remarks>
149+
/// <param name="rm">Pointer to the plugin measure</param>
150+
/// <param name="type">Log type (LOG_ERROR, LOG_WARNING, LOG_NOTICE, or LOG_DEBUG)</param>
151+
/// <param name="message">Message to be logged</param>
152+
/// <returns>No return type</returns>
153+
/// <example>
154+
/// <code>
155+
/// RmLog(rm, LOG_NOTICE, L"I am a 'notice' log message with a source");
156+
/// </code>
157+
/// </example>
158+
LIBRARY_EXPORT void __stdcall RmLog(void* rm, int level, LPCWSTR message);
159+
160+
/// <summary>
161+
/// Sends a formatted message to the Rainmeter log
162+
/// </summary>
163+
/// <remarks>LOG_DEBUG messages are logged only when Rainmeter is in debug mode</remarks>
164+
/// <param name="rm">Pointer to the plugin measure</param>
165+
/// <param name="level">Log level (LOG_ERROR, LOG_WARNING, LOG_NOTICE, or LOG_DEBUG)</param>
166+
/// <param name="format">Formatted message to be logged, follows printf syntax</param>
167+
/// <param name="...">Comma separated list of args referenced in the formatted message</param>
168+
/// <returns>No return type</returns>
169+
/// <example>
170+
/// <code>
171+
/// std::wstring notice = L"notice";
172+
/// RmLogF(rm, LOG_NOTICE, L"I am a '%s' log message with a source", notice.c_str());
173+
/// </code>
174+
/// </example>
175+
LIBRARY_EXPORT void __cdecl RmLogF(void* rm, int level, LPCWSTR format, ...);
176+
177+
/// <summary>
178+
/// DEPRECATED: Use RmLog. Sends a message to the Rainmeter log.
179+
/// </summary>
180+
LIBRARY_EXPORT BOOL __cdecl LSLog(int level, LPCWSTR unused, LPCWSTR message);
181+
182+
//
183+
// Wrapper functions
184+
//
185+
186+
#ifndef LIBRARY_EXPORTS
187+
/// <summary>
188+
/// Retrieves the option defined in the skin file and converts a relative path to a absolute path
189+
/// </summary>
190+
/// <param name="rm">Pointer to the plugin measure</param>
191+
/// <param name="option">Option name to be read from skin</param>
192+
/// <param name="defValue">Default value for the option if it is not found or invalid</param>
193+
/// <returns>Returns the absolute path of the option value as a string (LPCWSTR)</returns>
194+
/// <example>
195+
/// <code>
196+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
197+
/// {
198+
/// LPCWSTR path = RmReadPath(rm, L"MyPath", L"C:\\");
199+
/// }
200+
/// </code>
201+
/// </example>
202+
__inline LPCWSTR RmReadPath(void* rm, LPCWSTR option, LPCWSTR defValue)
203+
{
204+
LPCWSTR relativePath = RmReadString(rm, option, defValue, TRUE);
205+
return RmPathToAbsolute(rm, relativePath);
206+
}
207+
208+
/// <summary>
209+
/// Retrieves the option defined in the skin file and converts it to an integer
210+
/// </summary>
211+
/// <remarks>If the option is a formula, the returned value will be the result of the parsed formula</remarks>
212+
/// <param name="rm">Pointer to the plugin measure</param>
213+
/// <param name="option">Option name to be read from skin</param>
214+
/// <param name="defValue">Default value for the option if it is not found, invalid, or a formula could not be parsed</param>
215+
/// <returns>Returns the option value as an integer</returns>
216+
/// <example>
217+
/// <code>
218+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
219+
/// {
220+
/// int value = RmReadInt(rm, L"Value", 20);
221+
/// }
222+
/// </code>
223+
/// </example>
224+
__inline int RmReadInt(void* rm, LPCWSTR option, int defValue)
225+
{
226+
return (int)RmReadFormula(rm, option, defValue);
227+
}
228+
229+
/// <summary>
230+
/// Retrieves the option defined in the skin file and converts it to a double
231+
/// </summary>
232+
/// <remarks>If the option is a formula, the returned value will be the result of the parsed formula</remarks>
233+
/// <param name="rm">Pointer to the plugin measure</param>
234+
/// <param name="option">Option name to read from skin</param>
235+
/// <param name="defValue">Default value for the option if it is not found, invalid, or a formula could not be parsed</param>
236+
/// <returns>Returns the option value as a double</returns>
237+
/// <example>
238+
/// <code>
239+
/// PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
240+
/// {
241+
/// double value = RmReadDouble(rm, L"Value", 20.0);
242+
/// }
243+
/// </code>
244+
/// </example>
245+
__inline double RmReadDouble(void* rm, LPCWSTR option, double defValue)
246+
{
247+
return RmReadFormula(rm, option, defValue);
248+
}
249+
250+
/// <summary>
251+
/// Retrieves the name of the measure
252+
/// </summary>
253+
/// <remarks>Call RmGetMeasureName() in the Initialize function and store the results for later use</remarks>
254+
/// <param name="rm">Pointer to the plugin measure</param>
255+
/// <returns>Returns the current measure name as a string (LPCWSTR)</returns>
256+
/// <example>
257+
/// <code>
258+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
259+
/// {
260+
/// Measure* measure = new Measure;
261+
/// *data = measure;
262+
/// measure->myName = RmGetMeasureName(rm); // 'measure->myName' defined as a string (LPCWSTR) in class scope
263+
/// }
264+
/// </code>
265+
/// </example>
266+
__inline LPCWSTR RmGetMeasureName(void* rm)
267+
{
268+
return (LPCWSTR)RmGet(rm, RMG_MEASURENAME);
269+
}
270+
271+
/// <summary>
272+
/// Retrieves a path to the Rainmeter data file (Rainmeter.data).
273+
/// </summary>
274+
/// <remarks>Call GetSettingsFile() in the Initialize function and store the results for later use</remarks>
275+
/// <returns>Returns the path and filename of the Rainmeter data file as a string (LPCWSTR)</returns>
276+
/// <example>
277+
/// <code>
278+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
279+
/// {
280+
/// Measure* measure = new Measure;
281+
/// *data = measure;
282+
/// if (rmDataFile == nullptr) { rmDataFile = RmGetSettingsFile(); } // 'rmDataFile' defined as a string (LPCWSTR) in global scope
283+
/// }
284+
/// </code>
285+
/// </example>
286+
__inline LPCWSTR RmGetSettingsFile()
287+
{
288+
return (LPCWSTR)RmGet(NULL, RMG_SETTINGSFILE);
289+
}
290+
291+
/// <summary>
292+
/// Retrieves an internal pointer to the current skin
293+
/// </summary>
294+
/// <remarks>Call GetSkin() in the Initialize function and store the results for later use</remarks>
295+
/// <param name="rm">Pointer to the plugin measure</param>
296+
/// <returns>Returns a pointer to the current skin</returns>
297+
/// <example>
298+
/// <code>
299+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
300+
/// {
301+
/// Measure* measure = new Measure;
302+
/// *data = measure;
303+
/// measure->mySkin = RmGetSkin(rm); // 'measure->mySkin' defined as a 'void*' in class scope
304+
/// }
305+
/// </code>
306+
/// </example>
307+
__inline void* RmGetSkin(void* rm)
308+
{
309+
return (void*)RmGet(rm, RMG_SKIN);
310+
}
311+
312+
/// <summary>
313+
/// Retrieves full path and name of the skin
314+
/// </summary>
315+
/// <remarks>Call GetSkinName() in the Initialize function and store the results for later use</remarks>
316+
/// <param name="rm">Pointer to the plugin measure</param>
317+
/// <returns>Returns the path and filename of the skin as a string (LPCWSTR)</returns>
318+
/// <example>
319+
/// <code>
320+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
321+
/// {
322+
/// Measure* measure = new Measure;
323+
/// *data = measure;
324+
/// skinName = RmGetSkinName(rm); } // 'measure->skinName' defined as a string (LPCWSTR) in class scope
325+
/// }
326+
/// </code>
327+
/// </example>
328+
__inline LPCWSTR RmGetSkinName(void* rm)
329+
{
330+
return (LPCWSTR)RmGet(rm, RMG_SKINNAME);
331+
}
332+
333+
/// <summary>
334+
/// Returns a pointer to the handle of the skin window (HWND)
335+
/// </summary>
336+
/// <remarks>Call GetSkinWindow() in the Initialize function and store the results for later use</remarks>
337+
/// <param name="rm">Pointer to the plugin measure</param>
338+
/// <returns>Returns a handle to the skin window as a HWND</returns>
339+
/// <example>
340+
/// <code>
341+
/// PLUGIN_EXPORT void Initialize(void** data, void* rm)
342+
/// {
343+
/// Measure* measure = new Measure;
344+
/// *data = measure;
345+
/// measure->skinWindow = RmGetSkinWindow(rm); } // 'measure->skinWindow' defined as HWND in class scope
346+
/// }
347+
/// </code>
348+
/// </example>
349+
__inline HWND RmGetSkinWindow(void* rm)
350+
{
351+
return (HWND)RmGet(rm, RMG_SKINWINDOWHANDLE);
352+
}
353+
354+
/// <summary>
355+
/// DEPRECATED: Use RmLog(rm, type, message). Sends a message to the Rainmeter log.
356+
/// </summary>
357+
__inline void RmLog(int level, LPCWSTR message)
358+
{
359+
LSLog(level, NULL, message);
360+
}
361+
362+
enum LOGLEVEL
363+
{
364+
LOG_ERROR = 1,
365+
LOG_WARNING = 2,
366+
LOG_NOTICE = 3,
367+
LOG_DEBUG = 4
368+
};
369+
#endif // LIBRARY_EXPORTS
370+
371+
#endif

API/x32/Rainmeter.lib

4.56 KB
Binary file not shown.

KeyCodeInfo/AssemblyInfo.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
[assembly: AssemblyCopyright("© 2024 - NS Tech Bytes 🇵🇰")]
5+
[assembly: AssemblyVersion("1.0")]
6+
7+
// Do not change the entries below!
8+
#if X64
9+
[assembly: AssemblyInformationalVersion("3.0.2.2161 (64-bit)")]
10+
#else
11+
[assembly: AssemblyInformationalVersion("3.0.2.2161 (32-bit)")]
12+
#endif
13+
[assembly: AssemblyProduct("Rainmeter")]

0 commit comments

Comments
 (0)