[英]How to store and handle the window
im am a beginner first, I wanna use this HWND hwnd = FindWindow("ThunderRT6FormDC", BlueStack") to get hwnd program that i want get. and How to store and handle the BlueStack window when it have more than 2 BlueStack,我首先是初学者,我想使用这个 HWND hwnd = FindWindow("ThunderRT6FormDC", BlueStack") 来获取我想要的 hwnd 程序。以及如何存储和处理 BlueStack window 当它有超过 2 个 BlueStack 时,
HWND hwnd = FindWindow("ThunderRT6FormDC", BlueStack");
DWORD pid;
float temp = 0;
GetWindowThreadProcessId(hwnd, &pid);
HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, pid);
Use EnumWindows()
to get a list of all windows, get the class name and the title and compare them to filter out anything that doesn't match your search queries使用EnumWindows()
获取所有 windows 的列表,获取 class 名称和标题并比较它们以过滤掉与您的搜索查询不匹配的任何内容
#include <iostream>
#include <windows.h>
static BOOL CALLBACK enumWindowCallback(HWND hWnd, LPARAM lparam)
{
int length = GetWindowTextLength(hWnd);
char* title = new char[length + 1];
GetWindowText(hWnd, title, length + 1);
char classname[200]{ 0 };
GetClassName(hWnd, classname, 200);
if (!_stricmp("BlueStack", title) && !_stricmp("ThunderRT6FormDC", classname))
{
std::cout << hWnd << ": " << title << " class name: " << classname << std::endl;
}
delete[] title;
return TRUE;
}
int main() {
std::cout << "Enmumerating windows..." << std::endl;
EnumWindows(enumWindowCallback, NULL);
std::cin.ignore();
return 0;
}
This will output all windows which match这将 output 所有 windows 匹配
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.