circusdei wrote:
> I wrote this snippet with the intention of -- capturing a section of
> the screen whenever it changes.  It could be implemented to log any
> sort of messaging system ( by saving consecutive images eg.
> 1.png...etc).
> 
> #code --------------------
> 
> import Image
> import ImageGrab
> lastchatbound = (21, 504) + (189, 516)
> img1 = ImageGrab.grab(lastchatbound)
> data1 = list(img1.getdata())
> img2 = ImageGrab.grab(lastchatbound)
> data2 = list(img2.getdata())
> # print `data1`
pictnumber = 0
> if data1 != data2:
>     img1.save(`picnumber` + '.png')
>     picnumber = picnumber + 1
>     else:
>         print "same"
> 
> #code ------------------
> 
> it doesn't work yet and i'm not quite sure how the loops work yet ( i
> just sarted python last week). any help anyone could give me would be
> appreciated.
> 
> if someone could rewrite it so it works, i could use that as an example
> for the future, thanks.
> 
> - mb
> 
At the first glance the code looks almost ok. It is a good habit always 
to attach documentation of the error messages if any.
What I can directly see is, that you need at least to initialize the 
picnumber (see above).
Look in the Python documentation for the chapter with loops, read about 
the time module you will need to let the loop pause before taking the 
next screenshot and consider also, that maybe later it would be a good 
idea to have a way to stop the loop executing.
Come back with the next revision of your code for further help if you 
get into trouble or wait until someone else provides you with 
appropriate working code.

Claudio
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to