mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added !SetWallpaper bang.
Usage: !SetWallpaper [File] (Style) where style is CENTER, TILE, STRETCH, FIT, or FILL. FIT/FILL available only on Windows 7 (and higher).
This commit is contained in:
parent
913cf05a18
commit
405976b7a6
@ -420,6 +420,30 @@ void CRainmeter::Bang_SetClip(const WCHAR* arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Bang_SetWallpaper
|
||||||
|
**
|
||||||
|
** !SetWallpaper bang
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
void CRainmeter::Bang_SetWallpaper(const WCHAR* arg)
|
||||||
|
{
|
||||||
|
std::vector<std::wstring> subStrings = ParseString(arg);
|
||||||
|
|
||||||
|
if (subStrings.size() == 1)
|
||||||
|
{
|
||||||
|
CSystem::SetWallpaper(subStrings[0], L"");
|
||||||
|
}
|
||||||
|
else if (subStrings.size() == 2)
|
||||||
|
{
|
||||||
|
CSystem::SetWallpaper(subStrings[0], subStrings[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(LOG_ERROR, L"!SetWallpaper: Invalid parameters");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Bang_SkinMenu
|
** Bang_SkinMenu
|
||||||
**
|
**
|
||||||
@ -1756,6 +1780,10 @@ void CRainmeter::ExecuteBang(const std::wstring& name, std::wstring& arg, CMeter
|
|||||||
{
|
{
|
||||||
Bang_SetClip(args);
|
Bang_SetClip(args);
|
||||||
}
|
}
|
||||||
|
else if (_wcsicmp(bang, L"SetWallpaper") == 0)
|
||||||
|
{
|
||||||
|
Bang_SetWallpaper(args);
|
||||||
|
}
|
||||||
else if (_wcsicmp(bang, L"About") == 0)
|
else if (_wcsicmp(bang, L"About") == 0)
|
||||||
{
|
{
|
||||||
CDialogAbout::Open(args);
|
CDialogAbout::Open(args);
|
||||||
|
@ -221,6 +221,7 @@ private:
|
|||||||
void Bang_ToggleConfig(const WCHAR* arg);
|
void Bang_ToggleConfig(const WCHAR* arg);
|
||||||
void Bang_DeactivateConfigGroup(const WCHAR* arg);
|
void Bang_DeactivateConfigGroup(const WCHAR* arg);
|
||||||
void Bang_SetClip(const WCHAR* arg);
|
void Bang_SetClip(const WCHAR* arg);
|
||||||
|
void Bang_SetWallpaper(const WCHAR* arg);
|
||||||
void Bang_SkinMenu(const WCHAR* arg);
|
void Bang_SkinMenu(const WCHAR* arg);
|
||||||
void Bang_TrayMenu();
|
void Bang_TrayMenu();
|
||||||
void Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow);
|
void Bang_WriteKeyValue(const WCHAR* arg, CMeterWindow* meterWindow);
|
||||||
@ -309,17 +310,11 @@ private:
|
|||||||
GlobalConfig m_GlobalConfig;
|
GlobalConfig m_GlobalConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef LIBRARY_EXPORTS
|
|
||||||
#define EXPORT_PLUGIN __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define EXPORT_PLUGIN __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
EXPORT_PLUGIN int Initialize(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpCmdLine);
|
int Initialize(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpCmdLine);
|
||||||
EXPORT_PLUGIN void Quit();
|
void Quit();
|
||||||
EXPORT_PLUGIN void ExecuteBang(LPCTSTR szBang);
|
void ExecuteBang(LPCTSTR szBang);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "MeasureNet.h"
|
#include "MeasureNet.h"
|
||||||
#include "Error.h"
|
#include "Error.h"
|
||||||
|
|
||||||
|
using namespace Gdiplus;
|
||||||
|
|
||||||
#define DEBUG_VERBOSE (0) // Set 1 if you need verbose logging.
|
#define DEBUG_VERBOSE (0) // Set 1 if you need verbose logging.
|
||||||
|
|
||||||
#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)
|
#define ZPOS_FLAGS (SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE | SWP_NOSENDCHANGING)
|
||||||
@ -1176,6 +1178,92 @@ void CSystem::SetClipboardText(const std::wstring& text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** SetWallpaper
|
||||||
|
**
|
||||||
|
** Sets the system wallpapar.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
void CSystem::SetWallpaper(const std::wstring& wallpaper, const std::wstring& style)
|
||||||
|
{
|
||||||
|
auto setWallpaperStyle = [&]()
|
||||||
|
{
|
||||||
|
if (!style.empty())
|
||||||
|
{
|
||||||
|
HKEY hKey;
|
||||||
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, L"Control Panel\\Desktop", 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
const WCHAR* wallStyle = NULL;
|
||||||
|
const WCHAR* wallTile = L"0";
|
||||||
|
|
||||||
|
const WCHAR* option = style.c_str();
|
||||||
|
if (_wcsicmp(option, L"CENTER") == 0)
|
||||||
|
{
|
||||||
|
wallStyle = L"0";
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(option, L"TILE") == 0)
|
||||||
|
{
|
||||||
|
wallStyle = L"0";
|
||||||
|
wallTile = L"1";
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(option, L"STRETCH") == 0)
|
||||||
|
{
|
||||||
|
wallStyle = L"2";
|
||||||
|
}
|
||||||
|
else if (GetOSPlatform() >= OSPLATFORM_7)
|
||||||
|
{
|
||||||
|
if (_wcsicmp(option, L"FIT") == 0)
|
||||||
|
{
|
||||||
|
wallStyle = L"6";
|
||||||
|
}
|
||||||
|
else if (_wcsicmp(option, L"FILL") == 0)
|
||||||
|
{
|
||||||
|
wallStyle = L"10";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wallStyle)
|
||||||
|
{
|
||||||
|
RegSetValueEx(hKey, L"WallpaperStyle", 0, REG_SZ, (const BYTE*)wallStyle, sizeof(WCHAR) * 2);
|
||||||
|
RegSetValueEx(hKey, L"TileWallpaper", 0, REG_SZ, (const BYTE*)wallTile, sizeof(WCHAR) * 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(LOG_ERROR, L"!SetWallpaper: Invalid style");
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!wallpaper.empty())
|
||||||
|
{
|
||||||
|
if (GetOSPlatform() < OSPLATFORM_7)
|
||||||
|
{
|
||||||
|
// Gotta convert to .bmp for pre-7
|
||||||
|
Bitmap* bitmap = Bitmap::FromFile(wallpaper.c_str());
|
||||||
|
if (bitmap && bitmap->GetLastStatus() == Ok)
|
||||||
|
{
|
||||||
|
std::wstring file = Rainmeter->GetSettingsPath();
|
||||||
|
file += L"Wallpaper.bmp";
|
||||||
|
|
||||||
|
const CLSID jpegClsid = { 0x557cf400, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x0, 0x0, 0xf8, 0x1e, 0xf3, 0x2e } };
|
||||||
|
if (bitmap->Save(file.c_str(), &jpegClsid) == Ok)
|
||||||
|
{
|
||||||
|
setWallpaperStyle();
|
||||||
|
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)file.c_str(), SPIF_UPDATEINIFILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setWallpaperStyle();
|
||||||
|
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaper.c_str(), SPIF_UPDATEINIFILE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CopyFiles
|
** CopyFiles
|
||||||
**
|
**
|
||||||
|
@ -82,6 +82,7 @@ public:
|
|||||||
static void ResetWorkingDirectory();
|
static void ResetWorkingDirectory();
|
||||||
|
|
||||||
static void SetClipboardText(const std::wstring& text);
|
static void SetClipboardText(const std::wstring& text);
|
||||||
|
static void SetWallpaper(const std::wstring& wallpaper, const std::wstring& style);
|
||||||
|
|
||||||
static bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
static bool CopyFiles(const std::wstring& strFrom, const std::wstring& strTo, bool bMove = false);
|
||||||
static bool RemoveFile(const std::wstring& file);
|
static bool RemoveFile(const std::wstring& file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user