473,379 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Screen capturing on Windows


Is it possible by use of pyWin32 or ctypes to make a screen capture of
an inactive, or a hidden window if the hwnd/WindowName/ClassName is
known? I've seen dedicated screen capture software do this. While
PIL.ImageGrab.grab() is excellent, it will only capture the foreground
of the desktop. I've tried for hours, but I soon get helplessly lost in
the labyrinths of the Win32API.

Jun 13 '06 #1
2 10794

Rune Strand schrieb:
Is it possible by use of pyWin32 or ctypes to make a screen capture of
an inactive, or a hidden window if the hwnd/WindowName/ClassName is
known? I've seen dedicated screen capture software do this. While
PIL.ImageGrab.grab() is excellent, it will only capture the foreground
of the desktop. I've tried for hours, but I soon get helplessly lost in
the labyrinths of the Win32API.

As it says: the window is hidden. You can not make a screen shot of a
hidden
window 'cos it has no visual representation at the very moment. Simply
show it.
And if you do not want to see it while it's shown show it somewhere out
of the bounds of your virtual screen.

regards

Juergen

Jun 14 '06 #2
"Rune Strand" <ru*********@gmail.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com...

Is it possible by use of pyWin32 or ctypes to make a screen capture of
an inactive, or a hidden window if the hwnd/WindowName/ClassName is
known? I've seen dedicated screen capture software do this. While
PIL.ImageGrab.grab() is excellent, it will only capture the foreground
of the desktop. I've tried for hours, but I soon get helplessly lost in
the labyrinths of the Win32API.


This will restore a minimized window, bring it to the top and save a bmp.

import time
import win32gui, win32ui, win32con, win32api

def window_capture(window_title):
hwnd=win32gui.FindWindow(None, window_title)
if not hwnd:
raise 'Window not found'

print hwnd
win32gui.ShowWindow(hwnd,win32con.SW_RESTORE)
win32gui.SetForegroundWindow(hwnd)
time.sleep(0.1)
l,t,r,b=win32gui.GetWindowRect(hwnd)
h=b-t
w=r-l
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC=win32ui.CreateDCFromHandle(hwndDC)
saveDC=mfcDC.CreateCompatibleDC()
saveBitMap = win32ui.CreateBitmap()
saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)
saveDC.SelectObject(saveBitMap)
saveDC.BitBlt((0,0),(w, h) , mfcDC, (0,0), win32con.SRCCOPY)
temp_dir=win32api.GetTempPath()
bmpname=win32api.GetTempFileName(temp_dir,'wc')[0]+'.bmp'
saveBitMap.SaveBitmapFile(saveDC, bmpname)
return bmpname

Roger
Jun 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: dave | last post by:
Hi I have succesfully captured the users login detail, but I now have a new problem I have assigned the login to a Session Variable, however when I come to use the string stored in the variable it...
1
by: Jonny | last post by:
Hi all, Does anyone know how to capture the Windows Keys (I know that they are out of the ascii key range) and how to capture and record Mouse movements? Thanks, /Jonny
0
by: BK Kim | last post by:
Hello. I am tryring to find a way to capture some of the windows messages ( eg. messages for creating, deleting files ) in c#. In windows application, i can override wndProc method to capture...
8
by: Raj Thakkar | last post by:
Hi, I am currenty working on a site for intranet. I have a user control in the header of every page that will be displayed only if people with certain username are surfing the site. These lists...
0
by: NR | last post by:
Is there any possiblity to get screen dump of remote computer over LAN. Being LAN Administrator or having full rights can i get some details of client computer without asking for any client's...
1
by: Joachim | last post by:
Is it possible to write an application that captures screen happenings to a movie file of some format using MS DirectShow? If it is, where do I start?
2
by: =?Utf-8?B?TWFyaw==?= | last post by:
Does anyone know where there is some sample code that explains now a user; using the mouse can click on an image on the screen. Capture the image by boxing it in using the mouse and then save it to...
1
by: smart aditya | last post by:
hello, i am BE student working on my project. My project has an module in which i have to capture remote screen or live remote screen capture. After long search on web, i found many softwares...
0
by: Jeff jackson | last post by:
Is it possible to change the CTRL-ALT-DEL screen without changing the Login screen in Windows 7? Or better yet - can they have different screens? Thanks, -J
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.