sezzyaep Posted November 12, 2021 Share Posted November 12, 2021 if (g_cfg.esp.indicators[INDICATOR_MUSIC]) { std::string song_title = ""; static HWND spotify_hwnd = nullptr; static float last_hwnd_time = 0.f; int text_width = 0; if ((!spotify_hwnd || spotify_hwnd == INVALID_HANDLE_VALUE) && last_hwnd_time < m_globals()->m_realtime + 2.f) { for (HWND hwnd = GetTopWindow(0); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT)) { last_hwnd_time = m_globals()->m_realtime; if (!(IsWindowVisible)(hwnd)) continue; int length = (GetWindowTextLengthW)(hwnd); if (length == 0) continue; WCHAR filename[300]; DWORD pid; (GetWindowThreadProcessId)(hwnd, &pid); const auto spotify_handle = (OpenProcess)(PROCESS_QUERY_INFORMATION, FALSE, pid); (K32GetModuleFileNameExW)(spotify_handle, nullptr, filename, 300); std::wstring sane_filename{ filename }; (CloseHandle)(spotify_handle); if (sane_filename.find((L"Spotify.exe")) != std::string::npos) spotify_hwnd = hwnd; } } else if (spotify_hwnd && spotify_hwnd != INVALID_HANDLE_VALUE) { WCHAR title[300]; if (!(GetWindowTextW)(spotify_hwnd, title, 300)) { spotify_hwnd = nullptr; } else { std::wstring sane_title{ title }; std::string Title = " "; std::string Song(sane_title.begin(), sane_title.end()); Title += Song; if (sane_title.find((L"-")) != std::string::npos) { text_width = render::get().text_width(Title); render::get().text(fonts[NAME], 11, 11, Color(255, 255, 255, 220), HFONT_CENTERED_Y, Title.c_str()); song_title = Title; } else if (sane_title.find((L"Advertisment")) != std::string::npos) { text_width = render::get().text_width(fonts[NAME], "advertisment"); song_title = "advertisment"; } 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.