[SOLVED] How do AHK's A_ScreenWidth/Height work?
Posted: 20 Dec 2017, 15:56
Hey. I've been working on a C++ function to save a screenshot of the entire desktop to memory (for some cool computer vision stuff with OpenCV later) and I've run into a kinda weird problem: None of the Win32 APIs seem to be able to include the entire screen. Here's some of the things I've tried:
This prints out "1280" (for the screen width) 3 times. All these Win32 functions seem to "think" my screen is 1280x720. But if I look at the screen resolution settings, or call A_ScreenWidth/Height in AHK, I get 1920x1080; pressing PrintScreen also gives me a 1920x1080 image. After Googling myself stupid the only semi-related results I could find talked about multiple monitors. This kinda-sorta makes sense, because my workstation is a laptop that "docks" to a setup with a desktop-sized monitor... but then how do I get the "active" monitor? There doesn't seem to be such a concept (at least there doesn't seem to be anything like that on MSDN), but the Windows settings and AHK are obviously accessing "something else" to get the correct numbers. So I'm kind of grasping at straws here. Any ideas?
Code: Select all
// C++
std::cout << GetSystemMetrics(SM_CXVIRTUALSCREEN) << std::endl;
RECT r;
GetWindowRect(GetDesktopWindow(), &r);
std::cout << r.right << std::endl;
RECT r2;
GetClientRect(GetDesktopWindow(), &r2);
std::cout << r2.right << std::endl;