[python-win32] Creating a screenshot..
Andy Osagie
aeo120@psu.edu
Mon, 6 Jan 2003 13:05:03 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0002_01C2B584.4FD1DF60
Content-Type: text/plain;
charset="US-ASCII"
Content-Transfer-Encoding: 7bit
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? :-(
Are there any suggestions on alternate ways to accomplish my goal?
Thanks in advance.
-- Andy
------=_NextPart_000_0002_01C2B584.4FD1DF60
Content-Type: text/html;
charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{font-family:Arial;
color:windowtext;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Hello.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>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:</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'>win32api.keybd_event(win32con.VK_PRIN=
T, 0)</span></font></b></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'>win32clipboard.OpenClipboard(0)</span=
></font></b></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'>data =3D
win32clipboard.GetClipboardData(win32clipboard.CF_BITMAP)</span></font></=
b></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'>win32clipboard.CloseClipboard()</span=
></font></b></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'> </span></font></b></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>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? </span></font><font size=3D2 face=3DWingdings><span =
style=3D'font-size:
10.0pt;font-family:Wingdings'>L</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Are there any suggestions on alternate ways to =
accomplish my
goal? Thanks in advance.</span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'> </span></font></p>
<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>-- Andy</span></font></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'> </span></font></b></p>
<p class=3DMsoNormal><b><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;font-weight:bold'> </span></font></b></p>
</div>
</body>
</html>
------=_NextPart_000_0002_01C2B584.4FD1DF60--