
"""
Desktop_ScreenShot_Using_PIL_Demo.py
Original file name: screen.py

Simplified from :
http ://www.techontour.com/programming/2008/09/17/linux-windows-usage-surveillance-in-python/

"Linux [and Microsoft] Windows Usage Surveillance in Python"
"Part 1 : Python Screen Capture"

September 17th, 2008 by Skilla Repok

-----

ImageMagick and its add-on package for WX.Python also has the ability to take screenshots,
but is a cross-platform package.

As far as I know, PIL is only available for MSW platforms.

Ray Pasco   2010-03-23
pascor(at)verizon(dot)net

"""

import os, sys, platform
import shutil

isMSW = False
if os.name == 'nt' :
    isMSW = True
    import ImageGrab
else :      # Assume Linux/GTK
    from config import launchCommand
#end if

#------------------------------------------------------------------------------

def GrabScreen( filename ) :
    """
    Capture a screen shot of the current Desktop.
    For MSW platforms, only.
    """

    if platform.system() =='Windows' :
        img = ImageGrab.grab()      # ImageGrab is a module from the PIL package
        img.save( filename )        #  similar to the Image module.
        
    else :      # ??? Is this a Linux hack or always a perfectly acceptable command line :
        launchCommand( '/usr/bin/xwd -display  :0 -root -out %s' % filename )
    #end if
    
#end def

#==============================================================================

if __name__ == '__main__'  :
    
    GrabScreen( 'Desktop_ScreenShot_Using_PIL_Demo.png' )
    
#end if
