473,770 Members | 7,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.g rab() 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 10882

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.g rab() 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*********@gm ail.com> wrote in message news:11******** **************@ y43g2000cwc.goo glegroups.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.g rab() 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.F indWindow(None, window_title)
if not hwnd:
raise 'Window not found'

print hwnd
win32gui.ShowWi ndow(hwnd,win32 con.SW_RESTORE)
win32gui.SetFor egroundWindow(h wnd)
time.sleep(0.1)
l,t,r,b=win32gu i.GetWindowRect (hwnd)
h=b-t
w=r-l
hwndDC = win32gui.GetWin dowDC(hwnd)
mfcDC=win32ui.C reateDCFromHand le(hwndDC)
saveDC=mfcDC.Cr eateCompatibleD C()
saveBitMap = win32ui.CreateB itmap()
saveBitMap.Crea teCompatibleBit map(mfcDC, w, h)
saveDC.SelectOb ject(saveBitMap )
saveDC.BitBlt(( 0,0),(w, h) , mfcDC, (0,0), win32con.SRCCOP Y)
temp_dir=win32a pi.GetTempPath( )
bmpname=win32ap i.GetTempFileNa me(temp_dir,'wc ')[0]+'.bmp'
saveBitMap.Save BitmapFile(save DC, 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
2427
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 excludes the \ which seperates the domain from the user name, it should be :DOMAIN\USERNAME , but I am getting DOMAINUSERNAME which really is a pain. Anybody know why this is happening and how I can overcome it ? Thanks
1
1996
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
1423
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 OS's messages but in windows service application, i don't have the access to that. is there a way to access windows api(wndProc) directly to this?
8
3957
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 of usernames is stored on the server side in a xml based file So what I am doing at the moment is inside the user control pageload method, i get the username of the current person logged in using HttpContext.Current.User.Identity.Name and if the...
0
931
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 permisoin. Thanks in advance for any help. NR
1
2044
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
1916
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 a bitmap or onto another form? Thank you -- Mark
1
2664
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 doing this; But i want to do on my own through coding. So plz help
0
1383
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
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.