User talk:Py sunil

Screen Capture
The below code explains how to capture screen using a simple IronPython code.The Code is a simple windows forms application. The heart of the code is in cmdcaptureclicked function. Here screen class is used to get the screen width and height. Using Bitmap class we grab the image and buffered into a temporary memory. import clr

clr.AddReference("System") clr.AddReference("System.Data") clr.AddReference("System.Windows.Forms") clr.AddReference("System.Drawing");

from System import * from System.Drawing import * from System.Drawing.Drawing2D import * from System.Windows.Forms import *

frm = Form(Text="Capture Screen") frm.ClientSize = Size(290,288)

pb = PictureBox; pb.Location = Point(0,0) pb.Size = Size(100,50) frm.Controls.Add(pb)

def cmdcaptureclicked(sender,args): global frm frm.WindowState = FormWindowState.Minimized bmp = Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height); g = Graphics.FromImage(bmp); g.CopyFromScreen(0, 0, 0, 0, bmp.Size); g.Dispose; global pb	pb.Image = bmp; pb.Size = bmp.Size;

cmdcapture = Button cmdcapture.Text = "Capture Screen" cmdcapture.Location = Point(169,249) cmdcapture.Size = Size(110,30) cmdcapture.Click += cmdcaptureclicked frm.Controls.Add(cmdcapture)

def main: Application.EnableVisualStyles; global frm Application.Run(frm)

if(__name__ == "__main__"): main