[python-win32] Creating a screenshot..

Mark Hammond mhammond@skippinet.com.au
Tue, 7 Jan 2003 10:57:11 +1100


This is a multi-part message in MIME format.

------=_NextPart_000_00FD_01C2B63B.886CE9C0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

I would also look at PIL from www.pythonware.com - that may have a way of
grabbing the screen into an image.

Later versions of win32all work with more clipboard formats, and generally
allow you to specify the bimary data even when the format is not directly
recognised.

Mark.
  -----Original Message-----
  From: python-win32-admin@python.org
[mailto:python-win32-admin@python.org]On Behalf Of Andy Osagie
  Sent: Tuesday, 7 January 2003 5:05 AM
  To: python-win32@python.org
  Subject: [python-win32] Creating a screenshot..


  Hello.

  I was wondering how to create a screenshot of the user's screen and return
that data into a variable. I was told to look into the python win32
extensions and I did. The only idea I could come up with for accomplishing
my goal was the following:



  win32api.keybd_event(win32con.VK_PRINT, 0)

  win32clipboard.OpenClipboard(0)

  data = win32clipboard.GetClipboardData(win32clipboard.CF_BITMAP)

  win32clipboard.CloseClipboard()



  This, unfortunately, didn't work for two reasons. First: the first line
didn't successful recreate the act of the user pressing down the "Print
Screen" button. Pressing this down would have taken a screenshot of the
screen in bitmap format and pasted it to the clipboard. Second: I get a
"NotImplementedError" on line 3. Apparently "GetClipboardData" doesn't work
with the BITMAP type yet? L



  Are there any suggestions on alternate ways to accomplish my goal? Thanks
in advance.



  -- Andy





------=_NextPart_000_00FD_01C2B63B.886CE9C0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">


<META content=3D"MSHTML 6.00.2800.1126" name=3DGENERATOR>
<STYLE>@font-face {
	font-family: Wingdings;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
	FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"
}
A:link {
	COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
	COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
	COLOR: purple; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
	COLOR: purple; TEXT-DECORATION: underline
}
SPAN.EmailStyle17 {
	COLOR: windowtext; FONT-FAMILY: Arial
}
DIV.Section1 {
	page: Section1
}
</STYLE>
</HEAD>
<BODY lang=3DEN-US vLink=3Dpurple link=3Dblue>
<DIV><SPAN class=3D953195523-06012003><FONT face=3DArial color=3D#0000ff =
size=3D2>I=20
would also look at PIL from <A=20
href=3D"http://www.pythonware.com">www.pythonware.com</A> - that may =
have a way of=20
grabbing the screen into an image.</FONT></SPAN></DIV>
<DIV><SPAN class=3D953195523-06012003><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D953195523-06012003><FONT face=3DArial color=3D#0000ff =
size=3D2>Later=20
versions of win32all work with more clipboard formats, and generally =
allow you=20
to specify the bimary data even when the format is not directly=20
recognised.</FONT></SPAN></DIV>
<DIV><SPAN class=3D953195523-06012003><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D953195523-06012003><FONT face=3DArial color=3D#0000ff =

size=3D2>Mark.</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px =
solid; MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B>=20
  python-win32-admin@python.org =
[mailto:python-win32-admin@python.org]<B>On=20
  Behalf Of </B>Andy Osagie<BR><B>Sent:</B> Tuesday, 7 January 2003 5:05 =

  AM<BR><B>To:</B> python-win32@python.org<BR><B>Subject:</B> =
[python-win32]=20
  Creating a screenshot..<BR><BR></FONT></DIV>
  <DIV class=3DSection1>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hello.</SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I was wondering how to =
create a=20
  screenshot of the user&#8217;s screen and return that data into a =
variable. I was=20
  told to look into the python win32 extensions and I did. The only idea =
I could=20
  come up with for accomplishing my goal was the =
following:</SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">win32api.keybd_event(win32con.VK_PRINT,=20
  0)</SPAN></FONT></B></P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">win32clipboard.OpenClipboard(0)</SPAN></FONT></B></P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Arial">data =
=3D=20
  =
win32clipboard.GetClipboardData(win32clipboard.CF_BITMAP)</SPAN></FONT></=
B></P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">win32clipboard.CloseClipboard()</SPAN></FONT></B></P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"></SPAN></FONT></B>&nbsp;</P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">This, unfortunately, =
didn&#8217;t work=20
  for two reasons. First: the first line didn&#8217;t successful =
recreate the act of=20
  the user pressing down the &#8220;Print Screen&#8221; button. Pressing =
this down would=20
  have taken a screenshot of the screen in bitmap format and pasted it =
to the=20
  clipboard. Second: I get a &#8220;NotImplementedError&#8221; on line =
3. Apparently=20
  &#8220;GetClipboardData&#8221; doesn&#8217;t work with the BITMAP type =
yet? </SPAN></FONT><FONT=20
  face=3DWingdings size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Wingdings">L</SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Are there any =
suggestions on=20
  alternate ways to accomplish my goal? Thanks in =
advance.</SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial"></SPAN></FONT>&nbsp;</P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">-- =
Andy</SPAN></FONT></P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"></SPAN></FONT></B>&nbsp;</P>
  <P class=3DMsoNormal><B><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"></SPAN></FONT></B>&nbsp;</P></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00FD_01C2B63B.886CE9C0--