I love Python, I dislike Java. But Java is maintained by a large corporation and has some tools that Python does not. It is possible to write a program in Python, using Python's core library and Java's library in the same program and compile it in a Java bytecode executable. All you need is to download and setup JPython. Here are the implications of developing a program using JPython:
- Use both Java's and Python's libraries seamlessly in the same program.
- Will work on all platforms that Java works.
- Java's virtual machine is long to load (~3sec compared to Python's ~0.1 sec)
- Some functionalities of Java and of Python are not available in JYthon, and the documentation about that is not very good.
Here is the source file, you can execute it using jpython pyScreenSpy.py
#Pythons imports21 lines, in Python, using Java's libraries. How cool is that? Very!
from javax import imageio
from java import awt
from java.awt import image
from java import io
#Determine current screen size
toolkit = awt.Toolkit.getDefaultToolkit();
screenSize = toolkit.getScreenSize();
screenRect = awt.Rectangle(screenSize);
robot = awt.Robot();
image = robot.createScreenCapture(screenRect);
imageio.ImageIO.write(image, "jpg", io.File("test.jpg") );