Hey anyone please solve my problem. Here is the code, I have set the frame on top mode (it's optional) and I wanted that if I click mouse on the screen it should type "A" in the notepad (notepad is background application) but it is not working. As I click on the processing screen it becomes foreground application and notepad becomes background application and doesnt type anything in the notepad. PLEASE HELP
/*-----------------------------------------------*/
import java.awt.Robot;
import java.awt.AWTException;
import java.awt.event.KeyEvent;
import com.sun.awt.AWTUtilities;
import java.awt.GraphicsDevice.*;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
Robot robot;
void setup()
{
size(200, 200);
smooth();
frame.removeNotify();
frame.setAlwaysOnTop(true);
try {
robot = new Robot();
}
catch(AWTException a) {
println(a);
a.printStackTrace();
}
}
void draw()
{
background(255);
if (mousePressed) {
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
println("Pressed");
}
}