#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11

    Screen Shot Question


    I'm looking for some help getting python to take a screenshot. I searched online for something, but couldn't find anything. I checked the PIL as well. I basically want python to do the following:

    1. Notice movement on the screen
    2. take a screen shot
    3. Pass it on to a few if/else statements
    4. Click on the screen a particular button.

    1,2, and 4 I am unsure how to impliment, but using the PIL I can figure out 3.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    14
    Originally Posted by Noah_C
    I'm looking for some help getting python to take a screenshot. I searched online for something, but couldn't find anything. I checked the PIL as well. I basically want python to do the following:

    1. Notice movement on the screen
    2. take a screen shot
    3. Pass it on to a few if/else statements
    4. Click on the screen a particular button.

    1,2, and 4 I am unsure how to impliment, but using the PIL I can figure out 3.
    I think the better way of doing this is not by taking screenshots (since those often don't include the cursor and presumably you want to watch for cursor movement), but rather hooking into whatever window system the user is using. Whether it be the Win32 system or the X Window System or Aqua (or whatever the Mac OS windowing system is).
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11
    Well, I basically want to be able to play perfect blackjack in windows. So I basically would have it do the following steps.


    1. Take screen shot
    2. know that from (x,y) to (x,y) by (x,y) to (x,y) is card1, and then do that for all cards displayed.
    3. Pass that information on to some programming logic
    4. Respond by clicking a button in the program

    Is the win32 route still the right route to take ?

    Thank you for your suggestion.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by Strike
    I think the better way of doing this is not by taking screenshots (since those often don't include the cursor and presumably you want to watch for cursor movement), but rather hooking into whatever window system the user is using. Whether it be the Win32 system or the X Window System or Aqua (or whatever the Mac OS windowing system is).
    Yup, Mac OS X's Native Window System is called Aqua. But there's also a Mac port/application called X11 which is used to run X Window programs inside Mac OS X . Tend to be a little crappy looking though.

    http://www.apple.com/macosx/features/x11/
    http://www.apple.com/macosx/features/quartzextreme/
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11
    I found what I'm looking for.... PIL Handbook

    the Imagegrab.grab is what is needed, but I'm not sure how to use it. why won't the following code work ?

    Code:
    import sys
    import ImageGrab
    ImageGrab.grab(x0, y0, x1, y1) = im
    im.show()
  10. #6
  11. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Doesn't this require image recognition?
    How will your program know what cards are dealt, are face up, in the pile etc?

    hmmm ... You image grab assignment is a*** about face.

    grim
    Last edited by Grim Archon; November 24th, 2004 at 04:48 AM.

IMN logo majestic logo threadwatch logo seochat tools logo