Jump to content

PixelGetColor for a minimized window, I think i have the answer


_Kurt
 Share

Recommended Posts

I've read several articles over the web and I know for a fact it is possible.

I came accross an article explaining how to do it:

To capture any window, completely visible, partially visible, or complete invisible, Win32 API provides two special messages, WM_PRINT and WM_PRINTCLIENT. Both these messages take a device context handle as a parameter, and the window handling these messages is supposed to draw itself or its client area into the device context provided.

The author explains about how it can be done here, however I cannot translate any part of this to autoit.

Does his example work? Is this possible?

Thanks,

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

It's interesting.

I think this first simple method (without hooks, asm, etc.) can be modified to solve missing client area painted by WM_PAINT:

Here is original code:

void PrintWindow(HWND hWnd)
{
    HDC hDCMem = CreateCompatibleDC(NULL);

    RECT rect;

    GetWindowRect(hWnd, & rect);

    HBITMAP hBmp = NULL;

    {
        HDC hDC = GetDC(hWnd);
        hBmp = CreateCompatibleBitmap(hDC, rect.right - rect.left, rect.bottom - rect.top);
        ReleaseDC(hWnd, hDC);
    }

    HGDIOBJ hOld = SelectObject(hDCMem, hBmp);
    SendMessage(hWnd, WM_PRINT, (WPARAM) hDCMem, PRF_CHILDREN | PRF_CLIENT | PRF_ERASEBKGND | PRF_NONCLIENT | PRF_OWNED);

    SelectObject(hDCMem, hOld);
    DeleteObject(hDCMem);

    OpenClipboard(hWnd);

    EmptyClipboard(); 
    SetClipboardData(CF_BITMAP, hBmp);
    CloseClipboard();
}

I think there can maded second memory DC/bitmap and content of client area painted by WM_PAINT could be somehow copied to this second memory DC/bitmap. Then these two memory bitmaps can be combined together when they are moved to Clipboard.

It's just my idea.

Link to comment
Share on other sites

Yeah, I figured something like that out too. But all of this is too complicated for me, I don't have the knowledge or the understanding of C++ to translate. I'm not asking for someone to translate it, because that would be kind of lazy of me, but if anyone has any spare time and gets this working, it would be a great contribution to Example Scripts.

Thanks,

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

If I'm not mistaken, there is a section on that:

Handling WM_PRINTCLIENT Message without Source Code Change:

What if you do not have the source code of the window ?

Right?

Awaiting Diablo III..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...