From 6ea28e42ce4a2855546bcc181e10e74c74648ee0 Mon Sep 17 00:00:00 2001 From: DxxxxY Date: Sat, 9 Oct 2021 22:17:19 -0400 Subject: [PATCH] mute only league, hide client, add beeps, nircmd --- LeagueHider/Source.cpp | 63 ++++++++++++------------------------------ README.md | 24 +++++++++++----- 2 files changed, 34 insertions(+), 53 deletions(-) diff --git a/LeagueHider/Source.cpp b/LeagueHider/Source.cpp index 5e339a5..f1dcb44 100644 --- a/LeagueHider/Source.cpp +++ b/LeagueHider/Source.cpp @@ -1,60 +1,31 @@ #include #include -#include -#include - -//get all window titles -/*BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - if (!IsWindowVisible(hwnd)) return TRUE; - char class_name[250]; - char title[250]; - GetClassNameA(hwnd, class_name, sizeof(class_name)); - GetWindowTextA(hwnd, title, sizeof(title)); - std::cout << "Window title: " << title << std::endl; - std::cout << "Class name: " << class_name << std::endl << std::endl; - return TRUE; -}*/ -//test -IAudioEndpointVolume* GetEndpointVolume() { - HRESULT hr; - IMMDeviceEnumerator* deviceEnumerator = NULL; - hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID*)&deviceEnumerator); - IMMDevice* defaultDevice = NULL; - - hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &defaultDevice); - deviceEnumerator->Release(); - deviceEnumerator = NULL; - - IAudioEndpointVolume* endpointVolume = NULL; - hr = defaultDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (LPVOID*)&endpointVolume); - defaultDevice->Release(); - defaultDevice = NULL; - return endpointVolume; -} - -bool SetMute(bool mute) { - HRESULT hr; - CoInitialize(NULL); - IAudioEndpointVolume* endpointVolume = GetEndpointVolume(); - hr = endpointVolume->SetMute((bool)(mute), NULL); - endpointVolume->Release(); - CoUninitialize(); - return 0; -} bool close = false; int main() { - //EnumWindows(EnumWindowsProc, NULL); + Beep(900, 500); ShowWindow(GetConsoleWindow(), SW_HIDE); while (true) { if (GetAsyncKeyState(VK_INSERT)) { close = !close; - HWND hWnd = FindWindowA(NULL, "League of Legends (TM) Client"); //find the league client handle + HWND hWnd = FindWindowA(NULL, "League of Legends (TM) Client"); //find the league gamet handle + HWND hWnd2 = FindWindowA(NULL, "League of Legends"); //find the league client handle + ShowWindow(hWnd, close ? SW_HIDE : SW_SHOW); - SetMute(close); //system mute + ShowWindow(hWnd2, close ? SW_HIDE : SW_SHOW); + + std::system("nircmd.exe muteappvolume LeagueClientUxRender.exe 2"); + std::system("nircmd.exe muteappvolume LeagueClientUx.exe 2"); + + DWORD pid; + GetWindowThreadProcessId(hWnd, &pid); + CHAR buf[100]; + + sprintf_s(buf, sizeof(buf), "nircmd.exe muteappvolume /%d 2", pid); + + std::system(buf); } else if (GetAsyncKeyState(VK_END)) { Beep(500, 500); @@ -62,4 +33,4 @@ int main() { } Sleep(100); } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 07ea8b5..f30c264 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,22 @@ # LeagueHider -Hide the league client from desktop, taskbar and mute audio. Coded in C++. dxxxxy#5818. +ULTRA lightweight program for completely hiding League of Legends. Coded in C++. dxxxxy#5818. + +> Inspired by: strict parents, angry bosses and teachers. +## Requires +- [NirCmd](http://www.nirsoft.net/utils/nircmd.html) +> Drag it's files into C:\Windows ## Usage -Launch the `.exe` (download from [here](https://github.com/DxxxxY/LeagueHider/releases)) -> The app will sit in the background and wait for user inputs. ->> ~10kb file size, ~2mb memory usage, ~0% cpu usage. +Launch the `.exe` (download from [here](https://github.com/DxxxxY/LeagueHider/releases) or clone and compile by yourself) +> The app will hide itself just like it does for League and wait for [user inputs](#user-inputs). +>> ~10kb file size, ~0.6mb memory usage, ~0% cpu usage. + +### Sounds -### User Inputs -INSERT - Toggle for hiding/showing the game's window and muting audio. +Launching will produce a high pitched sound. -END - Quits the background process and plays a beep sound. +Quitting will produce a low pitched sound. +## User Inputs ++ INSERT - Master switch. +> Will hide League from desktop, alt-tab, taskbar, and mute it's audio. Only place where you can see League is in TaskManager. ++ END - Quits the process. \ No newline at end of file