Do you know how i can capture the image of each running window in the desktop?!
I want to do something similar to Windows powertoy that show me the thumbnail of each active window.
look at the attachment for an example
Do you know how i can capture the image of each running window in the desktop?!
I want to do something similar to Windows powertoy that show me the thumbnail of each active window.
look at the attachment for an example
Ok this doesn't really screen capture anything. It just iterates through the active programs. What you are looking for is called EnumWindows. Here is the description:
And here is the description of the user defined enum proc:EnumWindows
The EnumWindows function enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE.
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // callback function
LPARAM lParam // application-defined value
);
Parameters
lpEnumFunc
[in] Pointer to an application-defined callback function. For more information, see EnumWindowsProc.
lParam
[in] Specifies an application-defined value to be passed to the callback function.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If EnumWindowsProc returns zero, the return value is also zero.
And finally here is a simple sample code to show you how it all comes together:EnumWindowsProc
The EnumWindowsProc function is an application-defined callback function used with the EnumWindows or EnumDesktopWindows function. It receives top-level window handles. The WNDENUMPROC type defines a pointer to this callback function. EnumWindowsProc is a placeholder for the application-defined function name.
BOOL CALLBACK EnumWindowsProc(
HWND hwnd, // handle to parent window
LPARAM lParam // application-defined value
);
Parameters
hwnd
[in] Handle to a top-level window.
lParam
[in] Specifies the application-defined value given in EnumWindows or EnumDesktopWindows.
Return Values
To continue enumeration, the callback function must return TRUE; to stop enumeration, it must return FALSE.
Remarks
An application must register this callback function by passing its address to EnumWindows or EnumDesktopWindows
Code:#include <windows.h> #include <iostream> using namespace std; BOOL CALLBACK EnumProc(HWND hwnd,LPARAM lParam); int nNoWnd = 0; int main(void) { cout << "Enumerating..." << endl; EnumWindows((WNDENUMPROC) EnumProc,NULL); cout << "Total of " << nNoWnd << " windows" << endl; return 0; } BOOL CALLBACK EnumProc(HWND hwnd,LPARAM lParam) { char buff[MAX_PATH+1]; if(GetWindowText(hwnd,buff,MAX_PATH+1) <= 0) cout << "\"No Title\"" << endl; else cout << buff << endl; nNoWnd++; return TRUE; }
i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced
It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah
Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem