ecco la risposta per Windows (non so se alt + printScr funziona su Linux: P)
Credo che un modo per raggiungere questo
1. utilizzando la classe Robot al fuoco alt + comando printScreen (cattura la finestra attiva negli appunti)
2. leggere gli appunti!
Ecco le due parti di codice che lo fanno. Non ho provato in realtà, ma qualcosa che ho messo insieme.
Codice a fuoco i comandi per ottenere finestra attiva su appunti
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
public class ActiveWindowScreenShot
{
/**
* Main method
*
* @param args (not used)
*/
public static void main(String[] args)
{
Robot robot;
try {
robot = new Robot();
} catch (AWTException e) {
throw new IllegalArgumentException("No robot");
}
// Press Alt + PrintScreen
// (Windows shortcut to take a screen shot of the active window)
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_PRINTSCREEN);
robot.keyRelease(KeyEvent.VK_PRINTSCREEN);
robot.keyRelease(KeyEvent.VK_ALT);
System.out.println("Image copied.");
}
}
codice per leggere un'immagine su appunti
// If an image is on the system clipboard, this method returns it;
// otherwise it returns null.
public static Image getClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try {
if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
Image text = (Image)t.getTransferData(DataFlavor.imageFlavor);
return text;
}
} catch (UnsupportedFlavorException e) {
} catch (IOException e) {
}
return null;
}
È possibile gestire il controllo di cui hai bisogno a! Fammi sapere se questo funziona per te. ma questo è certamente il mio momento di provarlo!
Wow! Non ho mai pensato di farlo. Buon compagno di lavoro, ci proverò di sicuro. Buon Natale! –
Buon Natale! Si prega di provare e dire se funziona! Qualche cosa 'non si può fare in java' suonava troppo duro per le mie orecchie! : P – Shaunak
Non riesco a credere che non pensassi a questo a proposito di quanti fotogrammi al secondo puoi ottenere con questo. – user4090