mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	The !bangs can be now used from command line even if there are no active configs.
Included RainBrowser to the build.
This commit is contained in:
		| @@ -30,7 +30,7 @@ | |||||||
| BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass); | BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass); | ||||||
| HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinName); | HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinName); | ||||||
| LONG APIENTRY MainWndProc(HWND, UINT, UINT, LONG); | LONG APIENTRY MainWndProc(HWND, UINT, UINT, LONG); | ||||||
| void Bang(HWND hWnd, const WCHAR* command); | void Bang(const WCHAR* command); | ||||||
|  |  | ||||||
| /* | /* | ||||||
| ** Stuff from the DLL | ** Stuff from the DLL | ||||||
| @@ -38,7 +38,10 @@ void Bang(HWND hWnd, const WCHAR* command); | |||||||
| extern "C" EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR); | extern "C" EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR); | ||||||
| extern "C" EXPORT_PLUGIN void quitModule(HINSTANCE dllInst); | extern "C" EXPORT_PLUGIN void quitModule(HINSTANCE dllInst); | ||||||
| extern "C" EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine); | extern "C" EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine); | ||||||
| extern "C++" CRainmeter* Rainmeter; | extern "C" EXPORT_PLUGIN void ExecuteBang(LPCTSTR szBang); | ||||||
|  |  | ||||||
|  | const WCHAR* WinClass = L"DummyRainWClass"; | ||||||
|  | const WCHAR* WinName = L"Rainmeter control window"; | ||||||
|  |  | ||||||
| /*  | /*  | ||||||
| ** WinMain | ** WinMain | ||||||
| @@ -49,13 +52,18 @@ extern "C++" CRainmeter* Rainmeter; | |||||||
| int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) | int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) | ||||||
| { | { | ||||||
| 	MSG msg; | 	MSG msg; | ||||||
| 	WCHAR* WinClass = L"DummyRainWClass"; |  | ||||||
| 	WCHAR* WinName = L"Rainmeter control window"; |  | ||||||
| 	HWND hWnd; | 	HWND hWnd; | ||||||
|  |  | ||||||
| 	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | 	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); | ||||||
| //	_CrtSetBreakAlloc(5055); | //	_CrtSetBreakAlloc(5055); | ||||||
|  |  | ||||||
|  | 	if (lpCmdLine && lpCmdLine[0] == L'!') | ||||||
|  | 	{ | ||||||
|  | 		// It's a !bang | ||||||
|  | 		Bang(lpCmdLine); | ||||||
|  | 		return 0; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if(!hPrevInstance)  | 	if(!hPrevInstance)  | ||||||
| 	{ | 	{ | ||||||
| 		if (!InitApplication(hInstance, WinClass)) return FALSE; | 		if (!InitApplication(hInstance, WinClass)) return FALSE; | ||||||
| @@ -64,13 +72,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd | |||||||
| 	hWnd=InitInstance(hInstance, WinClass, WinName); | 	hWnd=InitInstance(hInstance, WinClass, WinName); | ||||||
| 	if(!hWnd) return FALSE; | 	if(!hWnd) return FALSE; | ||||||
|  |  | ||||||
| 	if (lpCmdLine && lpCmdLine[0] == L'!') |  | ||||||
| 	{ |  | ||||||
| 		// It's a !bang |  | ||||||
| 		Bang(hWnd, lpCmdLine); |  | ||||||
| 		return 0; |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// Remove quotes from the commandline | 	// Remove quotes from the commandline | ||||||
| 	WCHAR Path[256]; | 	WCHAR Path[256]; | ||||||
| 	Path[0] = 0; | 	Path[0] = 0; | ||||||
| @@ -162,20 +163,10 @@ HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinNa | |||||||
| ** Sends bangs to the DLL | ** Sends bangs to the DLL | ||||||
| ** | ** | ||||||
| */ | */ | ||||||
| void Bang(HWND hWnd, const WCHAR* command) | void Bang(const WCHAR* command) | ||||||
| { | { | ||||||
| 	// Check if Rainmeter is running | 	// Check if Rainmeter is running | ||||||
| 	HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL); | 	HWND wnd = FindWindow(WinClass, WinName); | ||||||
| 	if (wnd == NULL) |  | ||||||
| 	{ |  | ||||||
| 		// Check if all windows are "On Desktop" |  | ||||||
| 		HWND ProgmanHwnd = FindWindow(L"Progman", L"Program Manager"); |  | ||||||
| 		if (ProgmanHwnd) |  | ||||||
| 		{ |  | ||||||
| 			wnd = FindWindowEx(ProgmanHwnd, NULL, L"RainmeterMeterWindow", NULL); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if (wnd != NULL) | 	if (wnd != NULL) | ||||||
| 	{ | 	{ | ||||||
| 		COPYDATASTRUCT copyData; | 		COPYDATASTRUCT copyData; | ||||||
| @@ -185,13 +176,13 @@ void Bang(HWND hWnd, const WCHAR* command) | |||||||
| 		copyData.lpData = (void*)command; | 		copyData.lpData = (void*)command; | ||||||
|  |  | ||||||
| 		// Send the bang to the Rainmeter window | 		// Send the bang to the Rainmeter window | ||||||
| 		SendMessage(wnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)©Data); | 		SendMessage(wnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)©Data); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		if (wcsicmp(L"!rainmeterquit", command) != 0) | 		if (wcsicmp(L"!rainmeterquit", command) != 0) | ||||||
| 		{ | 		{ | ||||||
| 			MessageBox(hWnd, L"Rainmeter is not running.\nUnable to send the !bang to it.", L"Rainmeter", MB_OK); | 			MessageBox(NULL, L"Rainmeter is not running.\nUnable to send the !bang to it.", L"Rainmeter", MB_OK); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -213,6 +204,16 @@ LONG APIENTRY MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam) | |||||||
| 		} | 		} | ||||||
| 		break; | 		break; | ||||||
|  |  | ||||||
|  | 	case WM_COPYDATA: | ||||||
|  | 		{ | ||||||
|  | 			COPYDATASTRUCT* pCopyDataStruct = (COPYDATASTRUCT*) lParam; | ||||||
|  | 			if (pCopyDataStruct && (pCopyDataStruct->dwData == 1) && (pCopyDataStruct->cbData > 0)) | ||||||
|  | 			{ | ||||||
|  | 				ExecuteBang((const WCHAR*)pCopyDataStruct->lpData); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		break; | ||||||
|  |  | ||||||
| 	default: | 	default: | ||||||
| 		return (LONG)DefWindowProc(hWnd, message, wParam, lParam); | 		return (LONG)DefWindowProc(hWnd, message, wParam, lParam); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -660,6 +660,18 @@ CRainmeter::~CRainmeter() | |||||||
| 	GdiplusShutdown(m_GDIplusToken); | 	GdiplusShutdown(m_GDIplusToken); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /*  | ||||||
|  | ** ExecuteBang | ||||||
|  | ** | ||||||
|  | ** Runs a bang command. This is called from the main application | ||||||
|  | ** when a command is given as a command line argument. | ||||||
|  | ** | ||||||
|  | */ | ||||||
|  | void ExecuteBang(LPCTSTR szBang) | ||||||
|  | { | ||||||
|  | 	if (Rainmeter) Rainmeter->ExecuteCommand(szBang, NULL); | ||||||
|  | } | ||||||
|  |  | ||||||
| /*  | /*  | ||||||
| ** Initialize | ** Initialize | ||||||
| ** | ** | ||||||
| @@ -1958,6 +1970,7 @@ void CRainmeter::ShowContextMenu(POINT pos, CMeterWindow* meterWindow) | |||||||
| 			{ | 			{ | ||||||
| 				AppendMenu(configMenu, MF_SEPARATOR, 0, NULL); | 				AppendMenu(configMenu, MF_SEPARATOR, 0, NULL); | ||||||
| 				AppendMenu(configMenu, 0, ID_CONTEXT_OPENSKINSFOLDER, L"Open Skins\' Folder"); | 				AppendMenu(configMenu, 0, ID_CONTEXT_OPENSKINSFOLDER, L"Open Skins\' Folder"); | ||||||
|  | 				AppendMenu(configMenu, 0, ID_CONTEXT_MANAGESKINS, L"Manage Skins..."); | ||||||
|  |  | ||||||
| 				InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs"); | 				InsertMenu(subMenu, 3, MF_BYPOSITION | MF_POPUP, (UINT_PTR)configMenu, L"Configs"); | ||||||
| 			} | 			} | ||||||
|   | |||||||
| @@ -235,6 +235,7 @@ extern "C" | |||||||
| 	EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath); | 	EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath); | ||||||
| 	EXPORT_PLUGIN void quitModule(HINSTANCE dllInst); | 	EXPORT_PLUGIN void quitModule(HINSTANCE dllInst); | ||||||
| 	EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine); | 	EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine); | ||||||
|  | 	EXPORT_PLUGIN void ExecuteBang(LPCTSTR szBang); | ||||||
| } | } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -472,6 +472,12 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA | |||||||
| 				command += L"\\Addons\\RainThemes\\RainThemes.exe\""; | 				command += L"\\Addons\\RainThemes\\RainThemes.exe\""; | ||||||
| 				LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); | 				LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); | ||||||
| 			} | 			} | ||||||
|  | 			else if(wParam == ID_CONTEXT_MANAGESKINS) | ||||||
|  | 			{ | ||||||
|  | 				std::wstring command = L"\"" + Rainmeter->GetPath(); | ||||||
|  | 				command += L"\\Addons\\RainBrowser\\RainBrowser.exe\""; | ||||||
|  | 				LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL); | ||||||
|  | 			} | ||||||
| 			else if(wParam == ID_CONTEXT_QUIT) | 			else if(wParam == ID_CONTEXT_QUIT) | ||||||
| 			{ | 			{ | ||||||
| 				if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0); | 				if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0); | ||||||
|   | |||||||
| @@ -55,6 +55,7 @@ | |||||||
| #define ID_CONTEXT_OPENSKINSFOLDER       4044 | #define ID_CONTEXT_OPENSKINSFOLDER       4044 | ||||||
| #define ID_CONTEXT_SKINMENU_OPENSKINSFOLDER        4045 | #define ID_CONTEXT_SKINMENU_OPENSKINSFOLDER        4045 | ||||||
| #define ID_CONTEXT_MANAGETHEMES          4046 | #define ID_CONTEXT_MANAGETHEMES          4046 | ||||||
|  | #define ID_CONTEXT_MANAGESKINS          4047 | ||||||
|  |  | ||||||
| #define ID_CONFIG_EDIT                  30000 | #define ID_CONFIG_EDIT                  30000 | ||||||
| #define ID_CONFIG_FIRST                 30001 | #define ID_CONFIG_FIRST                 30001 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kimmo Pekkola
					Kimmo Pekkola