Attachment 'DesktopScreenShotPIL.py'
Download 1 """
2 Desktop_ScreenShot_Using_PIL_Demo.py
3 Original file name: screen.py
4
5 Simplified from :
6 http ://www.techontour.com/programming/2008/09/17/linux-windows-usage-surveillance-in-python/
7
8 "Linux [and Microsoft] Windows Usage Surveillance in Python"
9 "Part 1 : Python Screen Capture"
10
11 September 17th, 2008 by Skilla Repok
12
13 -----
14
15 ImageMagick and its add-on package for WX.Python also has the ability to take screenshots,
16 but is a cross-platform package.
17
18 As far as I know, PIL is only available for MSW platforms.
19
20 Ray Pasco 2010-03-23
21 pascor(at)verizon(dot)net
22
23 """
24
25 import os, sys, platform
26 import shutil
27
28 isMSW = False
29 if os.name == 'nt' :
30 isMSW = True
31 import ImageGrab
32 else : # Assume Linux/GTK
33 from config import launchCommand
34 #end if
35
36 #------------------------------------------------------------------------------
37
38 def GrabScreen( filename ) :
39 """
40 Capture a screen shot of the current Desktop.
41 For MSW platforms, only.
42 """
43
44 if platform.system() =='Windows' :
45 img = ImageGrab.grab() # ImageGrab is a module from the PIL package
46 img.save( filename ) # similar to the Image module.
47
48 else : # ??? Is this a Linux hack or always a perfectly acceptable command line :
49 launchCommand( '/usr/bin/xwd -display :0 -root -out %s' % filename )
50 #end if
51
52 #end def
53
54 #==============================================================================
55
56 if __name__ == '__main__' :
57
58 GrabScreen( 'Desktop_ScreenShot_Using_PIL_Demo.png' )
59
60 #end if
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.