gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
how to get all telegram's windows hwnd in c++?
- User
how to get all telegram's windows hwnd in c++?
- Assistant
To get all Telegram's windows' HWND in C++, you can use the Windows API functions
EnumWindowsandGetWindowTextalong with some additional checks. Here is an example code:#include <iostream> #include <vector> #include <windows.h> // Callback function to find Telegram windows BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) { char title[256]; GetWindowTextA(hwnd, title, sizeof(title)); // Check if the window title contains "Telegram" if (strstr(title, "Telegram") != NULL) { std::vector<HWND>* windows = reinterpret_cast<std::vector<HWND>*>(lParam); windows->push_back(hwnd); } return TRUE; } int main() { std::vector<HWND> telegramWindows; EnumWindows(EnumWindowsProc, reinterpret_cast<LPARAM>(&telegramWindows)); for (HWND hwnd : telegramWindows) { char title[256]; GetWindowTextA(hwnd, title, sizeof(title)); std::cout << "Window Title: " << title << std::endl; } return 0; }This code uses the
EnumWindowsfunction to enumerate all top-level windows and the function to retrieve the window title. The function is used to check if the window title contains the word "Telegram". If a match is found, the window's HWND is added to the vector.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.