[Tutor] windows api

elis aeris hunter92383 at gmail.com
Sun Dec 2 21:14:53 CET 2007


i know that site, i program in c++ on windows.

however, the syntax in different. how do I find out python's way of using
it?



On Dec 2, 2007 11:36 PM, bob gailer <bgailer at alum.rpi.edu> wrote:

> elis aeris wrote:
> > this code uses windows api, but where do I find documentation about
> > how to use them?
> Hmm - looks like something from Experts Exchange.
>
> If you are asking for the Windows API Reference, try:
>
> http://msdn2.microsoft.com/en-us/library/aa383749.aspx
>
> ctypes is a Python module that wraps the api calls
> >
> >
> >
> > import time
> > import ImageGrab # Part of PIL
> > from ctypes import *
> >
> >
> > #time.sleep(5)
> >
> >
> > # Load up the Win32 APIs we need to use.
> > class RECT(Structure):
> >     _fields_ = [
> >     ('left', c_ulong),
> >     ('top', c_ulong),
> >     ('right', c_ulong),
> >     ('bottom', c_ulong)
> >     ]
> >
> >
> > # time.sleep(2)
> >
> > GetForegroundWindow = windll.user32.GetForegroundWindow
> > GetWindowRect = windll.user32.GetWindowRect
> >
> > # Grab the foreground window's screen rectangle.
> > rect = RECT()
> > foreground_window = GetForegroundWindow()
> > GetWindowRect(foreground_window, byref(rect))
> > image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))
> >
> > # Save the screenshot as a BMP.
> > image.save("C:\projects\screenshot.bmp")
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071203/86a48f50/attachment.htm 


More information about the Tutor mailing list