3

I want to take a print screen of a particular window on my PC by running the python program and it taking that screen shot, before cropping it and comparing its hex value to other hex values in a SQL server.

I have thought about letting it wait 10 seconds whilst I get the other window up and then start taking the print screens continuously until one matches.

I was just wondering if I can use python to maximize that particular window that I want to print screen automatically and then have it take a print screen.

If not, could I take a print screen (a picture) of a window that is minimized? (I think this is impossible)..

Thanks!

Tom Pitts
  • 590
  • 7
  • 25
  • Your last paragraph which asks the question is not very clear. Could you try to fix that: maybe break it into a few sentences; be clear on whether "print screen" is a noun or a verb; etc? Are you just trying to open a gui program from within a python script? Or maybe you're trying to maximize a minimized window? Or maybe you're trying to do a screen capture at a particular time? – tom10 Oct 01 '14 at 20:30
  • Sorry, will change that now! – Tom Pitts Oct 01 '14 at 20:33

1 Answers1

1

If you do a quick Google search, you will find this helpful tutorial that uses PIL to take a screenshot of a desktop:

Assuming you're on Windows, you would need to use PyWin32 (or possibly pywinauto) to get the window you want. These two links will help with that:

Then you could use MoveWindow to resize the window you found before taking the screenshot:

Community
  • 1
  • 1
Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • Thanks, I was hoping to only use PIL but I think I've got to use PyWin32. – Tom Pitts Oct 01 '14 at 20:51
  • If you need to take a screenshot of a specific window that you didn't create (i.e. Notepad, MS Word, etc), then yes, you'll almost certainly need PyWin32 – Mike Driscoll Oct 01 '14 at 21:01