Obtain Active window using Python

On windows, you can use the python for windows extensions (http://sourceforge.net/projects/pywin32/): from win32gui import GetWindowText, GetForegroundWindow print GetWindowText(GetForegroundWindow()) Below code is for python 3: from win32gui import GetWindowText, GetForegroundWindow print(GetWindowText(GetForegroundWindow())) (Found this on http://scott.sherrillmix.com/blog/programmer/active-window-logger/)

Capture screenshot of active window?

Rectangle bounds = Screen.GetBounds(Point.Empty); using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using(Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } bitmap.Save(“test.jpg”, ImageFormat.Jpeg); } for capturing current window use Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(bounds.Left,bounds.Top), Point.Empty, bounds.Size); } bitmap.Save(“C://test.jpg”, ImageFormat.Jpeg); }