Is There a Python Equivalent to Java'S Awt Robot Class

Is there a Python equivalent to Java's AWT Robot class?

If you have GTK, then you can use the gtk.gdk.Display class to do most of the work. It controls the keyboard/mouse pointer grabs a set of gtk.gdk.Screen objects.

Java object method for Python's __int__():

The __int__ method in Python allows for a class to plug into the int() functionality built into the language - to "parse" an instance of an arbitrary class to an int.

There is not an equivalent in Java, but you could create a similar-looking construct. It would require you to be explicit.

public class Robot {
private int serial;

//ctor, getters, setters etc etc

public int toInt() {
return serial;
}

public static int toInt(Robot robot) {
return robot.toInt();
}
}

Then you can do something like

//some class, synax elided

import static com.pkg.Robot.toInt;

System.out.println(toInt(new Robot()));

As there is no int() functionality in Java, this doesn't really give you much over:

System.out.println(new Robot().toInt());

Or even the much more clear:

System.out.println(new Robot().getSerial());

If you want something more generic, you could create an interface:

public interface Intable {

int toInt();

}

Then you could implements the Interface in classes that you think should be able to turn themselves into an int.

Android API like java.awt.Robot

java.awt.Robot is not available in the Android SDK.

If you want to make screenshots by your own during development you can use DDMS. If your application should make screenshots, I think this requires root. There are application that can do that, e.g.

http://handheld.softpedia.com/get/Others/Screenshot-Android-71410.shtml

There is also a library available that may be useful for you:

Android Screenshot Library (ASL)

However, there is also a disucssion on SO:

How to capture the android device screen content?

Using custom Java keywords/library in Robot Framework using Jython

I used the .class file instead of a .jar, that seemed to solve the problem, no clue why the .jar didn't work though.



Related Topics



Leave a reply



Submit