Robot class.

With the robot class. I know their is the standered clas and then the Robot(GraphicsDevice screen) . Yes i know that the graphic device is for specifying another screen. But do u belive their is any thinkable way to specify to a specific window active on the computer?

I have no idea what you're talking about. But no, there is no way to specify the window.

Similar Messages

  • Robot class in Windows Vista

    Hello,
    It seems like there are problems with the java Robot class in Windows Vista.
    Did anyone encounter them?
    Thanks

    I didn't get your response, but I will try to explain myself.
    I have a problem with a program that I wrote that uses the Robot class and doesn't run well on Vista.
    I think that the operation system isn't letting it to control the mouse/keyboard: The program didn't crash,
    Simply didn't move the mouse although it was supposed to.
    I searched google for relevant information and the only relevant result I found was the link I posted.
    That link doesn't help me because in order to view the answer I have to pay money.
    I posted it because I thought that another description of the problem might help to understand it.

  • Taking screenshot with java applet using java robot class not working

    Hi Everyone,
    I am using the java applet to take screenshot of the web browser using the java's robot class.
    Robot objRobot = new Robot ();
    BufferedImage objBufferedImage = objRobot.createScreenCapture(objRectArea);
    The thing work good in windows system taking screenshot but in case of mac osx i get the blank image.When i check the event viewer in mac osx i get the following error.
    invalid context
    invalid pixel format
    CoreAnimation: rendering error 506
    The problem is coming for all the browser safari,firefox and chrome.My applet is signed applet.
    What might be the reason.An early reply is very valuable.
    My machine configuration is as follows.
    OS : MAC OSX
    Version : 10.6.4
    Is that a system level issue , java plugin issue?I'am confused with this error.
    Thanks sagar.

    870613 wrote:
    invalid context
    invalid pixel formatHm, seems like the Mac implementation of the Robot class is doing some bad initializations there. I can't be a 100% sure of course, but this smells like a bug to me. Are you sure you have the latest version of Java installed?

  • Robot class and positioning the cursor

    I have an application where I have a number of panels on the screen and using an editable field wish to enter coordinates to position the Cursor to on another panel.
    ie, using grid coordinates on a map. Using the robot class I am able to position the cursor on the other panel but as soon as I move the mouse the cursor jumps back to the original position on the screen where the first panel with the editable field was. It is like only a picture of the cursor was drawn at the new coordinates and the real cursor is still at the old podition. It is important to this application that if the cursor is moved it stays where it has been moved to and actually is there and not just appearing to be there. I am using jdk 1.3 on Intel Solaris 2.8. Any help on this issue would be helpful and appreciated

    Maybe you can use the mouse move event to position the mouse to where you had moved the cursor to.
    for example
    1.the mouse is at point 100,100
    2. you move the cursor from your code to point 0,0
    3. the user starts to move the mouse
    4. you code gets that event and repositions the cursor to the last place where it was, that is at 0,0

  • Alternative to Robot class

    hi have anyone an idea how can i make screenshoot from my scene without the class robot?
    at moment i use the Robot class to make screenshoots from my sceene
    Rectangle screenRect = new Rectangle(20,10,800,600);
             try{
                  Robot robot = new Robot();
                  BufferedImage image = robot.createScreenCapture(screenRect);
                  ImageIO.write(image, "png", new File(fileName));               
             } catch (AWTException e1) {}
                          catch (IOException e) {}         thats the code to make screenshoots but i think its not good to use AWT

    That depends: when modularity kicks in (Java 9 with early availability in Java 8?) you may end up with some light JVMs tailored for JavaFX-only without any AWT / Swing support. And if you are not connected to the Net (which is more common than you may think) you may not be able or want* to download the extra module(s) that give AWT / Swing support.
    *slow speed with limited amount size, expensive data plan, device without enough storage.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Robot class and keystrokes

    Can somebody help me? I have a 14000 plus line coded program. I need to generate software produced keystrokes. For example I would like to have my program hit the 'Enter' key instead of it being generated from the keyboard by a user. Now, I have just briefly been introduced to the Robot class and I am trying to understand it. I guess to use it I have to throw a AWTException. The problem is where I need to use the Robot class is in a JButton ActionListener(), which is on line 8000 nested in another frame. My question is how and where do I throw the AWTException in my program so that I can use the Robot class to generate an 'Enter' keystroke? I have noticed that in some sample programs the AWTException follows the opening
    public static void main(String[] args) throws AWTException
    statement. I tried attaching this in my program but the code nested in a AcitionListener did not recognize it.
    What I am hoping is that I can throw the exception in the following format:
    try
    Robot robot = new Robot();
    robot.keypressed(VK_ENTER);
    catch (AWTException exception)
    exception.printStackTrace();
    This is just a format I made up to show what I am looking for it has no actual copyright.
    I do not want to throw the AWTExecption for my whole program just this localized area when I need to have the software hit enter for me.
    Anyway, this is my problem can you help me out
    Derek.

    I just figured the problem out myself, by just guessing believe it or not.
    As follows :
    try
    Robot rob = new Robot():
    rob.keyPressed(VK_ENTER);
    catch(AWTException exception)
    exception.printStackTrace();
    It worked perfectly.

  • Differences between Robot class generated events and real input events

    Hello everyone!
    I'm having a problem with the translation of the description of the awt.Robot class.
    - "This class is used to generate native system input events" -
    Does this mean there is no difference between real input events and generated events from the Robot class? Difference in reference to that the generated events can't be recognized as generated events by the os or programs.
    Thanks in advance.
    Chris B.

    The Robot class will use an interface provided by the operating system to inject events. Those are very close to 'real' input events, but not quite there. There are, for instance, several games out there which have a protection mechanism against Robot's events to prevent scripting/botting. However, any application that is not paying special attention to the event's source will assume that the input events generated by Robot are actually coming from the user, so you can 'control' any application with the exception of the beforementioned games.

  • Robot class not working

    I need to make a macro with the robot class that draws a picture in a paint program. For each color in the image (256 colors total) it should change the paint color and drawing each 2x2 pixel that's that color. I made the program and it works correctly for about an hour, but then it starts slowing down a LOT, entering the wrong color codes, and drawing single pixels instead of 2x2.
    Here is the code for changing the color:
    robot.mouseMove (535, 504);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    robot.mouseMove (568, 410);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    for (i = 0; i < 6; i++)
        robot.keyPress (color.toUpperCase ().charAt (i));
    robot.keyPress (KeyEvent.VK_ENTER);
    robot.keyRelease (KeyEvent.VK_ENTER);Here is the code for drawing each pixel:
    robot.mouseMove (415 + (w * 2), 185 + (h * 2) - 1);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseMove (415 + (w * 2), 185 + (h * 2) + 1);
    robot.delay (100);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);Does anyone know why the robot stops working after about an hour?

    I'll guess that this might have something to do with it:
    for (i = 0; i < 6; i++)
        robot.keyPress (color.toUpperCase ().charAt (i));
        //need to release the key!
        robot.keyRelease (color.toUpperCase ().charAt (i));
    }Also, about your code to draw one pixel: it draws three pixels in a vertical line, at least in my paint program.

  • Drag events in Robot class

    I am using the Robot class in jdk1.3.1 to record and playback user input. I am getting the list of events and then traversing on it to do the appropriate action, mouse move, key events are played back fine, but I am unable to do mouse drag event.
    Here is simplified version of the code:
    for(int i = 0; i < aListEvents.size(); i++)
    AWTEvent event = (AWTEvent)aListEvents.get(i);
    Component c = (Component)event.getSource();
    int id = event.getID();
    switch(id)
    case MouseEvent.MOUSE_MOVED:
    int x = ((MouseEvent)e).getX();
    int y = ((MouseEvent)e).getY();
    m_robot.mouseMove(x,y);
    break;
    case KeyEvent.KEY_PRESSED:
    m_robot.keyPress(((KeyEvent)e).getKeyCode());
    break;
    case MouseEvent.MOUSE_DRAGGED:
         // do component drag
    break;
    Is there a way to mimic the drag event during playback and drag the object that was dragged during record?
    Any suggestions would be greatly appreciated!!
    Thanks :)

    This is an old posting, so the answer is probably too late for mamta and has also been answered elsewhere. But for whoever comes across this one, share my piece of experience:
    There's no one-to-one mapping between Java events and the system events (which is what Robot is refering to).
    After all, a MOUSE_DRAGGED is nothing but a MOUSE_MOVE after a MOUSE_PRESSED. So you can send a MOUSE_DRAGGED along to the robot as a mouseMove, because the Robot/system keeps in mind that the mouse button has been pressed before and therefor the event will appear in the Java event queue as a MOUSE_DRAGGED.
    Similar is MOUSE_CLICKED which needn't be replayed at all, because sending a MOUSE_PRESSED and a MOUSE_RELEASED to the Robot will automatically produce a MOUSE_CLICKED in the Java event queue as well.
    Same with the key strokes.

  • How to capture a screen by using robot class

    how to capture a screen by using robot class

    open the apidocs for the Robot class
    read the methods - you won't get far when one of the methods will stand out
    if you can't get it working, copy the method name and paste it into the 'search forums' box,
    where you'll find plenty of sample code

  • Doing Shift-End using Robot class

    I am trying to use the Robot class to do a Shift-End in order to select the text in a window from the cursor to the end of the line. However, the following code only moves the cursor to the end of the line without selecting the text.
    robot.keyPress(KeyEvent.VK_SHIFT);
    robot.keyPress(KeyEvent.VK_END);
    robot.keyRelease(KeyEvent.VK_END);
    robot.keyRelease(KeyEvent.VK_SHIFT);
    Note that I have been able to make the following code work. So the problem with the code above does not seem to be with the Shift key per se or with the ordering of the statements.
    robot.keyPress(KeyEvent.VK_SHIFT);
    robot.keyPress(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_A);
    robot.keyRelease(KeyEvent.VK_SHIFT);
    Any idea how to make the Shift-End work? I am using an XP PC.

    My ENTIRE code follows. Not surprisingly, the shiftEnd.actionPerformed gets a nullPointerException during execution. And being new to Java, I get the feeling I might be missing a whole bunch of stuff. For example, do I need to register for events? Do I need to generate a shift-End ActionEvent somehow? It is only the last 4 lines that are at issue here. Everything down to that point accomplishes what I want, i.e., position the mouse in a text window in the upper right-hand corner of my screen, move the cursor to the top of that window, then go down 5 lines. At that point, I want to do the shift-End to select all text in the line.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.KeyStroke;
    import javax.swing.JTextField;
    public class KeyStrokeTest {
    /** Creates a new instance of KeyStrokeTest */
    public KeyStrokeTest() {
    * @param args the command line arguments
    public static void main(String[] args)
    throws AWTException{
    Robot robot = new Robot();
    // Position mouse over Test Director test
    robot.mouseMove(600,300);
    // Press and release left mouse button to set focus in Test Director test
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    // Go to top of Test Director test
    robot.keyPress(KeyEvent.VK_CONTROL);
    robot.keyPress(KeyEvent.VK_HOME);
    robot.keyRelease(KeyEvent.VK_CONTROL);
    robot.keyRelease(KeyEvent.VK_HOME);
    // Go down to first line of request
    for(int i=0;i<5;i++) {
    robot.keyPress(KeyEvent.VK_DOWN);
    robot.keyRelease(KeyEvent.VK_DOWN);
    robot.delay(1000);
    // Do a shift End
    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_END,KeyEvent.VK_SHIFT);
    JTextField textComponent = new JTextField("String");
    ActionListener shiftEnd = textComponent.getActionForKeyStroke( keyStroke );
    shiftEnd.actionPerformed( null );

  • Why robot class doesnt get cursor

    i am using robot class , when i use createScreenCapture
    method it gets the everything on the screen but not the cursor.
    why? can i create i image that also get the cursor?
    many thanks

    MouseEvent provides a method:
    public Point getPoint()
    that returns the x,y position of the event relative to the source component.
    I guess it must be the archiect's view that the cursor is not a the screen, rather a device that points to the screen.
    -Merwyn
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Applet and Robot class???

    Alright, I want to write a java program uses the robot class (the class that allows for control of keybourd and mouse commands) would this work in an applet, or would it break the applet rules that ensure computer security on the web.

    i just want it to work on 1 computer, is there a way that i can override the things that dont work on the net?

  • Robot class slowing down

    I am using the robot class to make a macro that moves and clicks the mouse for a few hours. At first, the macro works correctly, and completes about five runs per second. However, after a few minutes the macro starts slowing down, and after an hour it is running through once every 10 seconds. Every run is exactly the same, so why could it be slowing down?

    Here's exactly what it's doing:
    1. get the color of the next pixel in a BufferedImage.
    2. make a robot and have it type the RGB values of the pixel into another window.
    3. move the mouse and click it a few times.
    I'm not using the hard drive. I'm not searching anything. I am not copying anything. Every run is exactly the same. Why is it getting slower as it runs? It finishes about a quarter of the image in 5 minutes, then hours later it has only done a few more rows.

  • Robot.class commands ignored by program

    Hi,
    I wrote a program that uses Robot.class to control some client application.
    It worked fine under windows XP.
    That was a while back and now I've tried it again and it doesn't work.
    Two things changes since then:
    I am using windows 7 now.
    I have a new version of the client application.
    My questions are:
    1. Is it possible to ignore commands coming from the robot class? How would the ignoring program know to do this? (normal mouse commands work of course)
    2. Is there some problem in windows 7 using the robot class? (i doubt it since in works on other windows but...)
    3. Is there any other way to send mouse/keyboard commands to other programs from java code?
    Thanks in advance for any help.

    As Andrew says, the Robot works fine on Windows 7, as 'fine' as such a class can work. What I mean by that?
    Applications based on the Robot class are inherently fragile and subject to failures when: screen resolution changes, UI themes are invoved, aero, client application changes or 'adapts' itself to another environment. This is especially true when it comes to mouse handling: a click at x,y that was hitting a button in environment A may hit nothing in B.
    So yes, the Robot works in Windows 7, but you may have to rewrite the application.
    By the way, after trying hard some ltime ago to use java and the Robot for such things and having to struggle with JNI to get something reasonable, I completely gave up and re-wrote it in C#. Even in C# I absolutely stayed away from the mouse, but my client application had keyboard support for al I needed. And even in C# I had to call native API's, but it's easier.
    Edited by: baftos on Nov 14, 2010 11:59 AM

Maybe you are looking for

  • Memory speed 5900 XT

    Why I can't overclock the memory clock of my GFX 5900XT at more than 740Mhz... When the card memory is set at more than 740Mhz some triangles appear in the screen while 3Dmark 03 or some games are running. What i need.... a better power supply or som

  • Multiple Apple IDs -- oh no!!

    This is sort of a universal problem with my apple account but I guess it manifests it self most in itunes because I buy songs and books on the itunes store. I somehow have three Apple IDs: one with my yahoomail address as my login name, one with my "

  • Need big help from moderator or host!

    I need some urgent help from someone who have the authority to delete my two - and only - post from the forum. I made the posts back in 2005 (using another profile) and still after all these years whenever you search for my real name in google, the p

  • Printing through DBMS_JOB

    Hi All, I've created a report from report bulider. Now, I want to create a procedure that will run the report for printing every end of the month. This procedure will be submitted to DBMS_JOB. How can I do this? or are there any other solution to acc

  • Pass WebI dimension multiple values to OpenDocument URL lsM parameter

    Hi Has anyone managed to pass multiple values of WebI dimension object to OpenDocument URL lsM parameter? My WebI document has 3 objects: Country  \[Country\] and Customer \[Customer\] dimensions and Sales Amount measure. WebI report includes a table