Гайд Showing spotify music in csgo

Забаненный
Статус
Оффлайн
Регистрация
5 Сен 2020
Сообщения
986
Реакции[?]
275
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
    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 )
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
6 Дек 2019
Сообщения
643
Реакции[?]
322
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
    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);
ну делать такое используя титл окна эт кнш пздц
 
Забаненный
Статус
Оффлайн
Регистрация
5 Сен 2020
Сообщения
986
Реакции[?]
275
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Memories of you
Эксперт
Статус
Оффлайн
Регистрация
14 Дек 2018
Сообщения
1,864
Реакции[?]
483
Поинты[?]
10K
CWDT User
Пользователь
Статус
Оффлайн
Регистрация
4 Фев 2019
Сообщения
330
Реакции[?]
53
Поинты[?]
1K
spotify api тебе на что?

через название окна это конечно гениально сделано, я даже с начала не понял
 
Пользователь
Статус
Оффлайн
Регистрация
12 Июн 2019
Сообщения
865
Реакции[?]
127
Поинты[?]
1K
spotify api тебе на что?

через название окна это конечно гениально сделано, я даже с начала не понял
спутифай апи в облаке.С++ явно создан не для веба и роботы с ним,хотя может
 
..................................................
Участник
Статус
Оффлайн
Регистрация
13 Авг 2020
Сообщения
990
Реакции[?]
249
Поинты[?]
25K
Было же

upd:
А, не, просто код скинули в вопросе
 
Эксперт
Статус
Оффлайн
Регистрация
3 Окт 2018
Сообщения
1,059
Реакции[?]
551
Поинты[?]
0
Тьомчик
Пользователь
Статус
Оффлайн
Регистрация
30 Июн 2020
Сообщения
698
Реакции[?]
148
Поинты[?]
56K
Последнее редактирование:
kill me
Забаненный
Статус
Оффлайн
Регистрация
18 Дек 2018
Сообщения
365
Реакции[?]
70
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
под лв
Код:
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";
                }
                else if (sane_title.find((L"Spotify")) != std::string::npos) {
                    text_width = render::get().text_width(fonts[NAME], "stopped / not playing");
                    song_title = "stopped / not playing";
                }
                else {
                    text_width = render::get().text_width(fonts[NAME], "advertisment");
                    song_title = "advertisment";
                }

            }
        }

        render::get().text(fonts[NAME], 10 + 1, 11 + 1, Color(0, 0, 0, 0), HFONT_CENTERED_Y, song_title.c_str());
        render::get().text(fonts[NAME], 10, 11, Color(255, 255, 255, 220), HFONT_CENTERED_Y, song_title.c_str());
    }
 
Пользователь
Статус
Оффлайн
Регистрация
19 Ноя 2019
Сообщения
263
Реакции[?]
50
Поинты[?]
2K
it works but crashes right after i turn it on :/
edit: managed to fix it, btw if there is an special letter the rest of the text cuts off, any fix?
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
5 Сен 2020
Сообщения
986
Реакции[?]
275
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Участник
Статус
Оффлайн
Регистрация
2 Фев 2020
Сообщения
818
Реакции[?]
378
Поинты[?]
0
Начинающий
Статус
Оффлайн
Регистрация
11 Окт 2020
Сообщения
197
Реакции[?]
22
Поинты[?]
0
я думал будет выводится панелька как в луа, но всё равно спасибоц
 
Сверху Снизу