-
Автор темы
- #1
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
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 < interfaces::globals->realtime + 2.f) {
for (HWND hwnd = GetTopWindow(0); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT)) {
last_hwnd_time = interfaces::globals->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 = renderer::text_width(Title);
renderer::draw_text(11, 11, color(255, 255, 255), Title.c_str());
song_title = Title;
}
else if (sane_title.find((L"Advertisment")) != std::string::npos) {
text_width = renderer::text_width("advertisment");
song_title = "advertisment";
}
else if (sane_title.find((L"Spotify")) != std::string::npos) {
text_width = renderer::text_width("stopped / not playing");
song_title = "stopped / not playing";
}
else {
text_width = renderer::text_width("advertisment");
song_title = "advertisment";
}
}
}
renderer::draw_text(10 + 1, 11 + 1, color(0, 0, 0), song_title);
renderer::draw_text(10, 11, color(255, 255, 255), song_title);
s/o @swoopae
( did not indicate credits because I did not know whose code it was, they gave it to me )
Последнее редактирование: