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

Similar Messages

  • 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

  • Why do I still get class or interface expected error????

    I made sure I closed all the bracket, why do i still get the error.
    Please help
    * ShopCartServletHW3.java
    * Created on November 19, 2007, 5:42 PM
    package ITI;
    import java.io.*;
    import java.net.*;
    import java.lang.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    * @author Administrator
    * @version
    public class ShopCartServletHW3 extends HttpServlet {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        private String pageTop01;
        private String pageTop02;
        private String pageTop03;
        private String pageTop04;
        private String pageTable01Top;
        private String pageTable01Bottom;
        private String pageBottom;
        private String pageItemEmpty;
        private String confirmTable01Bottom;
        private String confirmTableTop;
        private String confirmItemEmpty;
        private Hashtable pageItemList = new Hashtable();
        private Hashtable confirmItemList = new Hashtable();
        private double runningTotal;
        private ShopCartDataHW3 cartData;
        private InvTrackerHW3 invTracker;
        private Hashtable pastOrders;
        public void init() throws ServletException {
             PageTop01 = "<html>"
                    + "<head>"
                    + "<title>Blue Ridge Supply Shopping Cart </title>"
                    + "</head>"
                    + "<style type=\"text/css\">"
                    + "body {font-family: arial}"
                    + "h1 {color: navy}"
                    + "h2 {color: navy}"
                    + "h3 {color: white}"
                    + "h4 {color: white"
                    + "h5 {color: white}"
                    + "h6 {color: navy}"
                    + "p {color: navy}"
                    + "</style>"
                    + "<body>";
            pageTop02 = "<table border=\"0\" width=\"100%\" cellpadding=\"0\">"
                    + "<tr><td width=\"25%\" valign=\"top\">"
                    + "Shopper: ";
            pageTop03 = "<br>"
                    + "<a href=\"RegLoginServletHW3\"> [Log Out]</a>"
                    + " "
                    + "<a href=\"CatServletHW3\">[Continue Shopping]</a></td>"
                    + "<td width=\"50%\" valign=\"bottom\" align=\"center\"><h1>"
                    + "Blue Ridge Supply - Shopping Cart"
                    + "</h1>"
                    + "<td width=\"25%\" valign=\"top\" align=\"right\">"
                    + "Shopping Cart contains ";
            pageTop04 = " items </em> "
                    + "</td></tr></table><hr>";
            pageTable01Top = "<center><h3>"
                    + "Please review sections:"
                    + "</h3><table border=\"1\" cellpadding=\"10\" align=\"center\" valign=\"middle\" bgcolor=\"navy\">"
                    + "<tr><th><h4><br>"
                    + "Quantity"
                    + "</h4></th<th><h4>"
                    + "Item"
                    + "</h4></th><th><h4>"
                    + "Unit Price"
                    + "</h4></th></th><h4>"
                    + "Total Price"
                    + "</h4></th></tr>";
            pageBottom = "</body></html>";
        protected void processRequest(HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException {
            HttpSession session = request.getSession();
            if (session.isNew() || session == null) {
                sessionError( request, response);
            String userID;
            if (session.getAttribute("userID") != null) {
                userID = (String)session.getAttribute("userID");
            } else {
                sessionError( request, response);
                userID = "";
            Integer cartCount;
            if (session.getAttribute("cartCount") != null)
                cartCount = (Integer)session.getAttribute("cartCount");
            } else {
                sessionError( request, response);
                cartCount = Integer.valueOf(0);
            if (session.getAttribute("pastOrders") != null)
                pastOrders = (Hashtable)
                session.getAttribute("pastOrders");
                } else {
                sessionError( request, response);
                pastOrders = new Hashtable();
            if (session.getAttribute("invTracker") != null)
                invTracker = (InvTrackerHW3)
               session.getAttribute("invTracker");
            String shiptoname;
            String streetaddress;
            String city;
            String state;
            String zip;
            String shipservice;
            String cctype;
            String ccname;
            String ccnum;
            String ccexpmonth;
            String ccexpyear;
            // Shipping information
            Hashtable shipHash;
            if ((session.getAttribute("shipping") != null))
                shipHash = ((Hashtable)session.getAttribute("shipping"));
            } else {
                shipHash = new Hashtable();
            String [] shipping = new String[5];
            if (shipHash.get(userID) != null)  {
                shipping = (String[])shipHash.get(userID);
                shiptoname = shipping[0];
                streetaddress = shipping[1];
                city = shipping[2];
                state = shipping[3];
                zip = shipping[4];
            } else {
                shiptoname = "";
                streetaddress = "";
                city = "";
                state = "";
                zip = "";
            if ((session.getAttribute("shiptoname") != null)) {
            shiptoname = filter((String) session.getAttribute("shiptoname"))
            // Credit information
            if ((session.getAttribute("shipservice") != null)) {
                shipservice = filter((String) session.getAttribute("shipservice"));
            } else {
                shipservice = "";
            if ((session.getAttribute("ccname") != null)) {
                ccname = filter((String) session.getAttribute("ccname"));
            } else {
                ccname = "";     
            if ((session.getAttribute("cctype") != null)) {
                cctype = filter((String) session.getAttribute("cctype"));
            } else {
                cctype = "";
            if ((session.getAttribute("ccnum") != null)) {
                ccnum = filter((String)session.getAttribute("ccnum"));
            } else {
                ccnum = "";
            if ((session.getAttribute("ccexpmonth") != null)) {
                ccexpmonth = filter((String) session.getAttribute("ccexpmonth"));
            } else {
                ccexpmonth = "";
            if ((session.getAttribute("ccexpyear") != null)) {
                ccexpyear = filter((String) session.getAttribute("ccexpyear"));
            } else {
                ccexpyear = "";
            if (session.getAttribute("cart") != null && session.getAttribute("cartKeys") != null)
                cartData = new ShopCartDataHW3((Hashtable) session.getAttribute("cart"), (Hashtable)
                session.getAttribute("cartKeys"));
            else {
                cartData = new ShopCartDataHW3(new Hashtable(), new Hashtable());
            String itemToAdd;
            itemToAdd = (findItemAttribute(request, response));
            if ((itemToAdd != null) && (cartData.getItemID(itemToAdd) == null)) {
                cartData.updateItemID(itemToAdd, 1);
            if (itemToAdd != null) {
                int defaultValue = (cartData.getQty(itemToAdd).intValue());
                int x = getIntParameter(request, itemToAdd, defaultValue);
                if (x < 0) {
                    // do nothing
                } else {
                    cartData.updateItemID(itemToAdd, x);
           Hashtable cart = new Hashtable(cartData.getCart());
           Hashtable cartKeys = new Hashtable (cartData.getCartKeys());
           session.setAttribute("cart", cart);
           session.setAttribute("cartKeys", cartKeys);
           Integer numberOfKeys = new Integer (cartKeys.size());
           session.setAttribute("cartCount", numberOfKeys);
           runningTotal = 0;
           Enumeration keyValues = cartKeys.elements();
           while(keyValues.hasMoreElements()) {
               String key = (String) keyValues.nextElement();
               if (key != null) {
                   setCartPage(key, cartData);
                   setConfirmItemList(key, cartData);
           if (numberOfKeys.intValue() == 0) {
               setCartPage(null, cartData);
           String shippingAndCredit = loadShippingAndCredit(shiptoname, streetaddress, city, state, zip, shipservice, cctype, ccname, ccnum, ccexpmonth, ccexpyear);
           if (numberOfKeys.intValue() == 0) {
               session.setAttribute("confirm", "");
           } else {
               setConfirm(session, cartKeys, numberOfKeys);
           showPage(request, response, userID, cartKeys, numberOfKeys, shippingAndCredit);
        private void showPage(HttpServletRequest request,
                HttpServletResponse response, String userId, Hashtable cartKeys, Integer numberOfKeys, String shippingAndCredit)
                throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            out.println(pageTop01 + pageTop02 + userID + pageTop03 + numberOfKeys + pageTop04);
            out.println(shippingAndCredit);
            out.println(pageTable01Top);
            Enumeration keyValues = cartKeys.elements();
            while(keyValues.hasMoreElements()) {
                String key = (String)keyValues.nextElement();
                if (key != null) {
                    out.println(pageItemList.get(key));
            if (numberOfKeys.intValue() == 0) {
                out.println(pageItemEmpty);
            out.println(pageTable01Bottom + pageBottom);
            out.close();
        private String findItemAttribute(HttpServletRequest request,
                HttpServletResponse response)
                throws ServletException, IOException {
            Enumeration paramNames = request.getParameterNames();
            while(paramNames.hasMoreElements()) {
                String paramName = (String) paramNames.nextElement();
                CatalogHW3 item = new CatalogHW3();
                if (item.getItem(paramName) != null) {
                    return paramName;
            return null;
        private void setCartPage(String key, ShopCartDataHW3 cartData) {
            String pageItemFormat00 = "<form action=\"ShopCartServletHW3\" method=\"post\"><tr bgcolor=\"white\"><td align=\"center\">"
                    + "<input type=\text\" name=\"";
            String pageItemFormat01 = "\" value=\"";
            String pageItemFormat02 = "\" size=\"3\" align=\"right\">"
                    + "<input type=\"submit\" name=\"Update\" value=\"Update\" />"
                    + "<br>";
            String pageItemFormat03 = "</td><td><img src=\"";
            String pageItemFormat04 = "\" align=\"middle\" width=\"48\" height=\"48\"> ";
            String pageItemFormat05 = "</td><td align=\"right\">";
            String pageItemFormat06 = "</td><td align=\"right\">";
            String pageItemFormat07 = "</td></tr></form>";
            DecimalFormat f = new DecimalFormat();
            if (key != null)  {
                int qtyOnHand = invTracker.getQtyOnHand(key);
                int qtyAvailable = qtyOnHand - cartData.getQty(key).intValue();
                if (qtyAvailable < 0) {
                    cartData.updateItemID(key, invTracker.getQtyOnHand(key));
                    qtyAvailable = 0;
                double total = ((cartData.getQty(key).intValue() * cartData.getCost(key)));
                pageItemList.put(key,          pageItemFormat00
                + cartData.getItemID(key)
                                             + pageItemFormat01
                + cartData.getQty(key)
                                             + pageItemFormat02
                + qtyAvaliable + " More Avaliable "
                                             + pageItemFormat03
                + cartData.getImagePath(key)
                                             + pageItemFormat04
                + cartData.getDescription(key)
                                             + pageItemFormat05
                + "$" + f.format(cartData.getCost(key))
                                             + pageItemFormat06
                + "$" + f.format(total)
                                             + pageItemFormat07);
                runningTotal = total + runningTotal;
            } else {
                pageItemEmpty = "<tr bgcolor=\"white\"><td colspan=\"4\" align=\"center\">"
                        + "Your Shopping Cart is empty ... Please buy something."
                        + "</td></tr>";
                runningTotal = 0;
            pageTable01Bottom = "<tr><td colspan=\"4\" align=\"Right\"><h4> Total Order: $ "
                    + f.format(runningTotal)
                    + "</h4></td></tr></table>";
    private void setConfirmItemList(String key, ShopCartDataHW3 cartData) {
        confirmTableTop = "<center><h3>"
                + "Order Details"
                + "<table border=\"1\" cellpadding=\"10\" align=\"center\" valign=\"middle\">"
                + "<tr><th><h4><br>"
                    + "Quantity"
                    + "</h4></th<th><h4>"
                    + "Item"
                    + "</h4></th><th><h4>"
                    + "Unit Price"
                    + "</h4></th></th><h4>"
                    + "Total Price"
                    + "</h4></th></tr>";
        String confirmItemFormat00 = "<tr bgcolor=\"white\"><td align=\"center\">";
        String confirmItemFormat01 = "<td align=\"right\">";
        String confirmItemFormat02 = "</td><td>";
        String confirmItemFormat03 = "<img src =\"";
        String confirmItemFormat04 = "\" align=\"middle\" width=\"48\" height=\"48\"> ";
        String confirmItemFormat05 = "</td><td align=\"right\">";
        String confirmItemFormat06 = "</td><td align=\right\">";
        String confirmItemFormat07 = "</td></tr>";
        DecimalFormat f = new DecimalFormat();
        if (key != null) {
            double total = ((cartData.getQty(key).intValue() * cartData.getCost(key)));
            confirmItemList.put(key,
                                              confirmItemFormat01
                + cartData.getQty(key)
                                             + confirmItemFormat02
                                             + confirmItemFormat03
                + cartData.getImagePath(key)
                                             + confirmItemFormat04
                + cartData.getDescription(key)
                                             + confirmItemFormat05
                + "$" + f.format(cartData.getCost(key))
                                             + confirmItemFormat06
                + "$" + f.format(total)
                                             + confirmItemFormat07);
        confirmTable01Bottom = "<tr><td colspan=\"4\" align=\"Right\"><h4>TOTAL ORDER: $ "
                + f.format(runningTotal)
                + "</h4></td></tr></table>";
    private void setConfirm(HttpSession session,
            Hashtable cartKeys, Integer numberOfKeys)
            throws ServletException, IOException {
        StringBuffer confirm = new StringBuffer(confirmTableTop);
        Enumeration keyValues = cartKeys.elements();
        while(keyValues.hasMoreElements()) {
            String key = (String)keyValues.nextElement();
            if (key != null) {
                confirm.append((String)
                confirmItemList.get(key));
        if (key != null) {
            confirm.append((String)
            confirmItemList.get(key));
    confirm.append(confirmTable01Bottom);
    session.setAttribute("confirm", confirm.toString());
    private String loadShippingAndCredit(String shiptonmae, String streetaddress, String city, String state, String zip, String shipservice, String cctype, String ccname, String ccnum, String ccexpmonth, String ccexyear) {
        String credit01;
        String credit02;
        String credit03;
        String ship01;
        String ship02;
        String ship03;
        String ship04;
        String ship05;
        String ship06;
        credit01 = "<form action=\"PurchConfServletHW3\" method=\"post\">"
                + "<table border=\"1\" cellpadding=\"10\" bgcolor=\"navy\" align\"center\">";
        ship01  =   "<center><h3>"
                + "Please provide your billing and shipping information: "
                + "<input type=\"submit\" name=\"Submit Order\" value=\"Submit Order\" />"
                + "</h3></hr>";
        String
        bill01  = "<tr><td bgcolor=\"white\">"
                + "Card Type:"
                + "<br>"
                + "<select name=\"cctype\">"
                + "<option value=\"Visa\" selected=\"selected\"> Visa</option>"
                + "<option value=\"MasterCard\" selected=\"selected\"> MasterCard</option>"
                + "<option value=\"American Express\" selected=\"selected\">American Express</option>"
                + "</select><br>"
                + "Card Number:"
                + "<br>"
                + "<input type=\"text\" name=\"ccnum\" value=\"";
      credit02  = "\"><br>"
                + "Cardholder Name:"
              + "<br>"
              + "<input type=\"text\" name=\"ccname\" value=\"";
      credit03  = "\"><br>"
                + "Expiration Date:"
              + "<br>"
              + "<select name=\"ccexpmonth\">"
              + "<option value=\"Jan\">Jan</option>"
              + "<option value=\"Feb\">Feb</option>"
              + "<option value=\"Mar\">Mar</option>"
              + "<option value=\"Apr\">Apr</option>"
              + "<option value=\"May\">May</option>"
              + "<option value=\"Jun\">Jun</option>"
              + "<option value=\"Jul\">Jul</option>"
              + "<option value=\"Aug\">Aug</option>"
              + "<option value=\"Sep\">Sep</option>"
              + "<option value=\"Oct\">Oct</option>"
              + "<option value=\"Nov\">Nov</option>"
              + "<option value=\"Dec\">Dec</option>"
              + "</select>"
              + "</td>";
      String
      ship00  = "<td bgcolor=\"white\">"
              + "Ship To Name:"
              + "<br>"
              + "<input type=\"text\" name=\"shiptoname\" size=\"37\" value=\"";
      ship02  = "\"<br>"
              + "Street Address:"
              + "<br>"
              +  + "<input type=\"text\" name=\"streetaddress\" size=\"37\" value=\"";
      ship03  = "\"<br>"
              + "City State Zip:"
              + "<br>"
              + "<input type=\"text\" name=\"city\" size=\"20\" value=\"";
      ship04  = "\">"
              + "<input type=\"text\" name=\"state\" size=\"2\" value=\"";
      ship05  = "\">"
              + "<input type=\"text\" name=\"zip\" size=\"5\" value=\"";
      ship06  = "\"</td>";
      String
      ship00a = "<td bgcolor=\"white\">"
              + "<input type=\"radio\" checked=\"checked\" name=\"shipservice\" value=\"UPS Ground\">UPS Ground"
              + "<br><br>"
              + "<input type=\"radio\"  name=\"shipservice\" value=\"UPS 2nd Day Air\">UPS 2nd Day Air"
              + "<br><br>"
              + "<input type=\"radio\"  name=\"shipservice\" value=\"FedEx Priority\">FedEx Priority"
              + "<br><br>"
              + "<input type=\"radio\"  name=\"shipservice\" value=\"FedEx Ultra\">FedEx Ultra"
              + "</td>";
      String
      ship00c = "</tr>"
              + "</table></form>";
      return credit01
              + ship01
              + bill01
              + ccnum
              + credit02
              + ccname
              + credit03
              + ship00
              + shiptoname
              + ship02
              + ship03
              + streetaddress
              + city
              + ship04
              + state
              + ship05
              + zip
              + ship06
              + ship00a
              + ship00c;
    private void sessionError(HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        String sessionErrorForm;
        sessionErrorForm = "<form action=\"RegLoginServletHW3\" method=\"post\"><tr bgcolor=\"white\"> <td align=\"center\">"
                + "<h3 align=\"center\">Your request has not been processed - some isseues were found. <br> Please return to the Login page. </h3>"
                + "<input type=\"submit\" name=\"Go to Login\" value=\"Go to Login\" /></form>";
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println(pageTop01 + sessionErrorForm);
        out.close();
    private String filter(String input) {
        StringBuffer filter = new StringBuffer(input.length());
        char c;
        for(int i=0; i<input.length(); i++) {
            c = input.charAt(i);
            if (c == '<') {
                filtered.append("<");
            } else if ( c == '>') {
                filtered.append(">");
            } else if ( c == '"') {
                filtered.append(""");
            } else if (c == '&') {
                filtered.append("&");
            } else {
                filtered.append(c);
        return(filtered.toString());
    private int getIntParameter(HttpSevletRequest request,
            String paramName,
            int defaultValue) {
        String paramString = request.getParameter(paramName);
        int paramValue;
        try {
            paraValue = Integer.parseInt(paramString);
        } catch (NumberFormatException nfe) { // null or bad format
            paramValue = defaultValue;
        return(paramValue);
    //<editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** Handles the HTTP <code>GET</code>method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    /** Handles the HTTP <code>POST</code>method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
        return "Short description";
    // </editor-fold>
    }

    When you have errors, you should post them.
    I got 72 errors when I tried to compile the code you posted. Many of them are due to syntax errors like { and } not lining up.

  • Why to i keep getting a multi-colored circle in place of the cursor right before the browser shuts down on me??

    why do i keep getting a multi-colored circle in place of the cursor right before the browser shuts down on me??

    Open Control Panel -> Check in Mouse Properties -> Remove Checkmark from "Display Pointer Trails"
    Check and tell if its working.

  • Today I accidentally erased my Mac data....while I restart everything getting blank.....I try recover it by Internet by my MacBook don't even find my wifi...i have fail to restore it after all....why MacBook lion doesnt provide any recover tumb driver?

    Today I accidentally erased my Mac data....while I restart everything getting blank.....I try recover it by Internet by my MacBook don't even find my wifi...i have fail to restore it after all....why MacBook lion doesnt provide any recover tumb driver?

    It doesn't work...while I press the option button only shown up the internet recovery...I do have wifi..but my MacBook can not find my network at all...how?
    Why MacBook book lion doesn't provided any tumb drive recovery as previously?

  • Why is the green bar in the timeline so short? it doesnt get any bigger. I use cs4

    Why is the green bar in the timeline so short? it doesnt get any bigger. I use cs4

    but even though I have a layer it doesnt go long shooternz

  • SET and GET cursor

    Hi all!
    How can I get the field where the cursor is placed in a component?
    Thanks in advance!!!

    Hi.
    using html tag you can trigger the "OnMouseOver" event.
    Here you are an example:
    1) An input field: 
    < input type="text"  name="name"  on_mouseover="ACTION"  />
    where "ACTION" could be a javascript or a bsp standard event,  and
    on_mouseover  must be replaced with  onmouseover (i don't know why but sdn doesnt' let me include the right statement).
    Hope this will be helpfull.
    Fabri

  • 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 );

  • 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.

  • Regarding sy-lilli, Get cursor line

    Hi Folks,
    I'm having some trouble with getting the cursor line in a search help selection.
    This is my code:
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield        = 'XBLNR'
                dynpprog        = sy-repid
                dynpnr          = sy-dynnr
                dynprofield     = 'ITAB-FACTURA'
                window_title    = 'Facturas'
                value_org       = 'S'
           TABLES
                value_tab       = itab_bsik_v[]
                return_tab      = return_tab
           EXCEPTIONS
                parameter_error = 1
                no_values_found = 2
                OTHERS          = 3.
      IF sy-subrc = 0.
      ENDIF.
      GET CURSOR LINE l_linea.
      READ TABLE itab_bsik_v INDEX l_linea.
      DATA: l_stepl LIKE  sy-stepl,
             l_indx  LIKE  sy-stepl.
      DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.
    * Adjust for scroling within table control
      CALL FUNCTION 'DYNP_GET_STEPL'
           IMPORTING
                povstepl        = l_stepl
           EXCEPTIONS
                stepl_not_found = 0
                OTHERS          = 0.
      l_indx = grid-top_line + l_stepl - 1.
      REFRESH dynpfields.
      CLEAR   dynpfields.
      dynpfields-fieldname  = 'ITAB-FACTURA'.
      dynpfields-fieldvalue = itab_bsik_v-xblnr.
      dynpfields-stepl      = l_stepl.
      APPEND dynpfields.
      dynpfields-fieldname  = 'ITAB-BUZEI'.
      dynpfields-fieldvalue = itab_bsik_v-buzei.
      dynpfields-stepl      = l_stepl.
      APPEND dynpfields.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
           EXPORTING
                dyname     = sy-repid  "Program name
                dynumb     = sy-dynnr  "Screen number
           TABLES
                dynpfields = dynpfields
           EXCEPTIONS
                OTHERS     = 0.
    The internal table itab_bsik_v is filled with 10 records. So when user clicks on record 5, I would expect that l_linea gets 5 as cursor line, however I'm getting 1 always.
    I tried changing the GET CURSOR LINE by sy-lilli but I'm not understanding really well the sy-lilli variable because when I click the first line of the search help result, I get a 4 as the index, and when I click in the last line I get 13.
    If anyone could help me with this I really appreciate it.
    Thanks for your help.
    Regards,
    Gilberto Li

    Instead of using GET CURSOR LINE why not u use return_tab.
    This int. table should contins data selected ny user during F4 help. I have done few changes in ur code. pl. check whether it works or not.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
           EXPORTING
                retfield        = 'XBLNR'
                dynpprog        = sy-repid
                dynpnr          = sy-dynnr
                dynprofield     = 'ITAB-FACTURA'
                window_title    = 'Facturas'
                value_org       = 'S'
           TABLES
                value_tab       = itab_bsik_v[]
                return_tab      = return_tab
           EXCEPTIONS
                parameter_error = 1
                no_values_found = 2
                OTHERS          = 3.
      IF sy-subrc = 0.
      ENDIF.
    GET CURSOR LINE l_linea.*
    READ TABLE itab_bsik_v INDEX l_linea.*
      read table return_tab into l_wa_return
                      with key fieldname = 'XBLNR'.
      if sy-subrc eq 0.
       l_XBLNR = l_wa_return-fieldval.
      endif.
      read table return_tab into l_wa_return
                      with key fieldname = 'BUZEI'.
      if sy-subrc eq 0.
       l_BUZEI = l_wa_return-fieldval.
      endif.
      DATA: l_stepl LIKE  sy-stepl,
             l_indx  LIKE  sy-stepl.
      DATA: dynpfields        LIKE dynpread OCCURS 5 WITH HEADER LINE.
    Adjust for scroling within table control
      CALL FUNCTION 'DYNP_GET_STEPL'
           IMPORTING
                povstepl        = l_stepl
           EXCEPTIONS
                stepl_not_found = 0
                OTHERS          = 0.
      l_indx = grid-top_line + l_stepl - 1.
      REFRESH dynpfields.
      CLEAR   dynpfields.
      dynpfields-fieldname  = 'ITAB-FACTURA'.
      dynpfields-fieldvalue = l_XBLNR. 
       dynpfields-stepl      = l_stepl.
      APPEND dynpfields.
      dynpfields-fieldname  = 'ITAB-BUZEI'.
      dynpfields-fieldvalue =  l_BUZEI.
      dynpfields-stepl      = l_stepl.
      APPEND dynpfields.
      CALL FUNCTION 'DYNP_VALUES_UPDATE'
           EXPORTING
                dyname     = sy-repid  "Program name
                dynumb     = sy-dynnr  "Screen number
           TABLES
                dynpfields = dynpfields
           EXCEPTIONS
                OTHERS     = 0.

  • 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 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.

  • Why this path doesnt work when there is "!DOCTYPE" element?

    Hi, I need to extract contents from an xml file, which looks like
    <hr />
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE article PUBLIC "-//ES//DTD journal article DTD version 5.0.1//EN//XML" "xyz501.dtd" > <!-- LINE 1 -->
    <article docsubtype="fla">
    <item-info>
    <jid>YANBE</jid>
    <aid>12941</aid>
    </item-info>
    </article>
    <hr />
    And I have tested with this path "//article/item-info/jid/text()", but it doesnt give me anything. But I noticed that when I remove line 1, it does extract the content "YANBE"...
    why the path doesnt work when there is that DOCYTYPE element? How should I get around with this please?
    Many thanks!

    The extract of XML you gave is not valid (Line 1: <hr/>) but besides that ... I think your problem is in the DTD.
    Somewhere in the DTD it probably 'sneakily' defines a default attribute which in reality is a default-namespace for one of the elements. This means that in your XPath handling, you will have to map a prefix to a namespace-uri (NamespaceContext [1]) and use this newly defined prefix in your XPath expression.
    //tst:article/tst:item-info/tst:jid/text()[1] http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/namespace/NamespaceContext.html

Maybe you are looking for