I am trying to capture the image of the active window. It works well for one monitor, but what if there are multiple monitors?
The solution I use is:
if(auto handle = GetForegroundWindow(); handle != nullptr){
RECT rect;
GetWindowRect(handle, &rect);
auto screen_list = QGuiApplication::screens();
auto pixmap = screen_list[0]->grabWindow(0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
The problem is, how could I know which screen the active foreground belongs to when there are multiple windows?
Any API I could use to find out the relationship of the handle and the screen?