From timr at probo.com Mon May 1 02:12:44 2017 From: timr at probo.com (Tim Roberts) Date: Sun, 30 Apr 2017 23:12:44 -0700 Subject: [python-win32] Screenshot a given window instead of the whole desktop In-Reply-To: References: Message-ID: On Apr 28, 2017, at 5:40 PM, Michael C > wrote: I have my own code that samples pixel colour, https://pastebin.com/4EMd765h and now I am trying to add the feature of saving the Device Context to a .bmp file, so I found this code https://books.google.ca/books?id=9MS9BQAAQBAJ however there is one problem: The book example screenshots the whole desktop and I only want a screenshot of a given window. Is there a way to modify the black hat example into something that only screenshot a window given its handle? It would have been easier to help if you had showed us the code you're trying to modify. I assume the code you're copying does GetDC(0) to grab a DC for the desktop. If you instead pass the window handle of the window you want to snapshot, just pass that to GetDC. You'll want to use GetWindowRect to find the size of the window. ? Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mysecretrobotfactory at gmail.com Mon May 1 02:14:48 2017 From: mysecretrobotfactory at gmail.com (Michael C) Date: Mon, 01 May 2017 06:14:48 +0000 Subject: [python-win32] Screenshot a given window instead of the whole desktop In-Reply-To: References: Message-ID: I solved that problem already, i sould have told everyone here, sorry On Sun, Apr 30, 2017 at 11:13 PM Tim Roberts wrote: > On Apr 28, 2017, at 5:40 PM, Michael C > wrote: > > > I have my own code that samples pixel colour, > https://pastebin.com/4EMd765h > > and now I am trying to add the feature of saving the Device Context to a > .bmp file, so I found this code > > https://books.google.ca/books?id=9MS9BQAAQBAJ > > however there is one problem: The book example screenshots the whole > desktop and I only want a screenshot of a given window. Is there a way to > modify the black hat example into something that only screenshot a window > given its handle? > > > It would have been easier to help if you had showed us the code you're > trying to modify. > > I assume the code you're copying does GetDC(0) to grab a DC for the > desktop. If you instead pass the window handle of the window you want to > snapshot, just pass that to GetDC. You'll want to use GetWindowRect to > find the size of the window. > ? > Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > -------------- next part -------------- An HTML attachment was scrubbed... URL: