Go Down

Topic: Bringing dinosaurs back to life (Read 1 time) previous topic - next topic

acm01

Aug 15, 2011, 05:26 pm Last Edit: Aug 15, 2011, 09:15 pm by acm01 Reason: 1
Now that I've got your attention ;)

Ok so I'm gonna have a go at my 2nd arduino project, wish me luck :P

What I want to do is hack a keyboard and use mousekeys to gain control over my computers crusor. What I need to do is move the crusor down the vertical axis for a random (X) amount of time then right along the horizontal axis for a random (Y) amount of time and then click the button and move Y in the opposite direction (left) and X up. Then I need it to start again, with different random numbers

I know how to make the circuits and the basics of arduino control. I'm just not sure how to introduce multiple random numbers that will allow me to return to my original position.

That's probably not very clear so I drew an equally bad diagram :) Basically the top one is a graphical demostration of what I tried to say. And the bottom one is of my computer screen :D The aim of the project is to start at A, move to a random location in the B box, click, move back to A, then move to a random location in C box and click. Finally returning back to A.

Thanks for ANY help :)

bilbo

Can there be a program running on the computer in the background? If so, an arduino really is not necessary. See the robots class in java. A simple program using this could move the cursor however you like, no hardware necessary.

What are you trying to accomplish?
Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

robtillaart

Quote
Ok so I'm gonna have a go at my 2nd arduino project, wish me luck

good luck!

Quote
I'm just not sure how to introduce multiple random numbers that will allow me to return to my original position.


Idea: You have to add up all your delta's and subtract them from the end position to get to the original point.

This will fail when you hit the border, e.g. x=1000;  x = x + random(e.g 59) = 1059 is rounded to 1024 =>  oops! 35 pixels off.


In fact only WIndows knows where the mouse pointer is, a mouse has no clue at all. Those special haptic mouses with feedback are controlled from within windows. So in short There is no silver bullet for this problem. Best solution imho is to set the mousecursor to somewhere in the middle, probably the user will be flabbergasted and will not recall the original position.


Legal note: in some countries these kinds of jokes/gadgets are not appreciated legally

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

acm01

Em well I don't think I can use another program, it's for an online game that I've been trying to beat :P And they are very good at catching 'bots', using the random factor allows me to trick the game into thinking it's a real person, as they detect bots by seeing patterns in the areas clicked on. Using the arduino has worked in the past so I figure try using it again! And also, if I know the speed the crusor moves then surely I can put constraints on the random number generator built into the arduino so I can select the rough area of the screen it ends up on. I've done it before, I had a button be clicked down for a random time between 1 second and 3.5 seconds. Well I'm going to do the same thing again, using mouse keys, only problem is, I don't know how to make the arduino remember the first random number so that I can get back to the start position.... is that clearer? :s I always have problems explaining myself on this :'(

robtillaart

As said you can use an internal variables that sums all the random delta X's and the delta Y's so you constantly know the offset you made. This info helps you to keep you on screen.

pesudoCode()
Code: [Select]

for (int i=0; i< 100; i++)
{
  dx = random();  dy = random();
  sumx += dx;  sumy + dy;
  moveMouse(dx,dy);
}
moveMouse(-sumX, -sumY);

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

acm01

Oh sorry rob, get you now. Thanks for your help!

robtillaart


Repeating is part of communication :)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

bilbo

I think you are missing my point. You can accomplish this the exact same way from software alone. If you can use mousekeys, you can use a java or Processing program to simulate mouse moves. No arduino necessary. Same result accomplished, except easier cheaper and faster.
Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

robtillaart

Yep, missed your point, sorry .
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

bilbo

Haha sorry I was referring to the OP, because he seemed to think that a software and hardware solution would produce different results. Im all for arduino, but when something simpler would suffice, its only logical.
Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

acm01

Ok well the software option seems a good idea then! Is it capable of putting random movements within certain areas. Because if not I've thought of a simple solution using the arduino (which I already own) If I just make the mousekeys move the crusor to a corner of the screen each time (by pressing the movement button for a long period of time), then I've a garuntteed start point each time. But I'd like to look into the software idea. Thanks for all your help guys

bilbo

Its capable of doing whatever you program it to do. Basically, there is a class in Java called the Robot class http://download.oracle.com/javase/1.3/docs/api/java/awt/Robot.html , which has a function called mouseMove() which sends the cursor to a specific pair of coordinates. This class can be used in standard Java, or Processing if it is easier for you.
Alice asked the Chesire Cat, who was sitting in a tree, "What road do I take?"
The cat asked, "Where do you want to go?"
"I don't know," Ali

Go Up