Results 1 to 8 of 8
  1. #1
    slugy12345 is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Help With Robot mouseMove And Other Stuff!

    I recently got a new computer and went from 32 bit to 64 bit. I have this code using the robot and for some reason the robot part of the code is fine. It's just the the mousMove or the keyPress or something like that gets a red underline. Here is my code and I'm just trying to get rid of those errors. Please help me because when I first wrote this code it worked!

    PHP Code:
    import java.awt.event.InputEvent;
    import java.awt.event.KeyEvent;
    import java.util.concurrent.TimeUnit;
    import java.awt.Robot;
    import java.awt.AWTException;
    
    
    
    public class Robot {
    	public static void main (String[]args) throws Exception {
    		Robot r = new Robot();
    		
    		int x = 100;
    		int y = 100;
    		int i = 1;
    		
    		
    
    		
    		while (i<100) {
    		r.mouseMove(x, y);
    		TimeUnit.MILLISECONDS.sleep(1);
    		x++;
    		y++;
    		i++;
    		
    		}
    		
    		int c = 1;
    		
    		while (c<500) {
    		Robot.mouseMove(x, y);
    		TimeUnit.MILLISECONDS.sleep(1);
    		y++;
    		c++;
    		}
    		int v = 1;
    		while (v<175) {
    		Robot.mouseMove(x, y);
    		TimeUnit.MILLISECONDS.sleep(1);
    		y++;
    		x=x-1;
    		v++;
    		}
    		
    		int b=1;
    		while (b<125) {
    		Robot.mouseMove(x, y);
    		y++;
    		b++;
    	}
    		 Robot.mousePress(InputEvent.BUTTON1_MASK);
             Robot.mouseRelease(InputEvent.BUTTON1_MASK);
    	
    		 i = 0;
    		 while (i<50) {
    			 y=y-1;
    			 Robot.mouseMove(x, y);
    			 i=i+1;
    		 }
    	    
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_P);
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_A);
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_I);
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_N);
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_T);
    		TimeUnit.SECONDS.sleep(1);
    		Robot.keyPress(KeyEvent.VK_ENTER);
    		
    		
    		
    		
    	}
    
    }

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,985
    Rep Power
    9

    Default Re: Help With Robot mouseMove And Other Stuff!

    I assume you mean that your IDE is indicating a compilation error. What is that compilation error?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    slugy12345 is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by KevinWorkman View Post
    I assume you mean that your IDE is indicating a compilation error. What is that compilation error?
    Well when I mouse over it when it becomes underlined by a red underline, it says something about mouseMove or keyPress not being defined in the Robot type. That's the only issue I get when I mouse over it but when I run it this error comes:
    Java Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mousePress(int) is undefined for the type Robot
    	The method mouseRelease(int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    
    	at Robot.main(Robot.java:21)

  4. #4
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by slugy12345 View Post
    Well when I mouse over it when it becomes underlined by a red underline, it says something about mouseMove or keyPress not being defined in the Robot type. That's the only issue I get when I mouse over it but when I run it this error comes:
    Java Code:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method mousePress(int) is undefined for the type Robot
    	The method mouseRelease(int) is undefined for the type Robot
    	The method mouseMove(int, int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    	The method keyPress(int) is undefined for the type Robot
    
    	at Robot.main(Robot.java:21)
    Very sneaky problem. Your class is named Robot, java thinks you are talking about your Robot class when you initiate it. Change the name of your class and import the Robot class from java.

    Here is another tip, when iterating a fixed number of times, use a for loop. Much cleaner.

  5. #5
    slugy12345 is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by zFollette View Post
    Very sneaky problem. Your class is named Robot, java thinks you are talking about your Robot class when you initiate it. Change the name of your class and import the Robot class from java.

    Here is another tip, when iterating a fixed number of times, use a for loop. Much cleaner.
    Thanks I recently learned for loops because I made this code ages ago and I was just playing around but hey, thanks!

  6. #6
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by slugy12345 View Post
    Thanks I recently learned for loops because I made this code ages ago and I was just playing around but hey, thanks!
    No problem, Im glad I could help.

  7. #7
    slugy12345 is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by zFollette View Post
    No problem, Im glad I could help.
    Even though this program was useless because I just wanted it to open the start menu and then open paint and then draw something but it was nice that you helped me fix a really dumb error.

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,985
    Rep Power
    9

    Default Re: Help With Robot mouseMove And Other Stuff!

    Quote Originally Posted by slugy12345 View Post
    Well when I mouse over it when it becomes underlined by a red underline, it says something about mouseMove or keyPress not being defined in the Robot type. That's the only issue I get when I mouse over it but when I run it this error comes:
    I'm glad you got it figured out, but you really need to take the time to understand compilation errors and runtime exceptions. I highly recommend ditching the IDE and using a basic text editor and the command line until you have a firmer grasp on the basics.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. New to this stuff.. need help..
    By tkelley1620 in forum New To Java
    Replies: 3
    Last Post: 03-07-2012, 12:34 AM
  2. quick question about mouseMove()
    By sgthale in forum New To Java
    Replies: 24
    Last Post: 08-01-2011, 04:00 AM
  3. where the stuff goes?
    By Izabela in forum New To Java
    Replies: 16
    Last Post: 08-31-2010, 02:00 PM
  4. Replies: 6
    Last Post: 05-26-2010, 12:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •