// Nathan Loewen
// NeedForSpeed Bot
// 4/25/15
//
// This code will probably not directly work for everyone's computer. I'm using Windows 7 with a
// 1366/768 screen resolution (17" monitor). All the delays , Mouse.move(0,0,0) and multiple lines
// of mouse movement were due to eratic mouse movement. That's what I found that worked. If I do
// another bot I will definitely put more effort into getting Mouse.moveAbs to work. Good luck.
// Sorry for the somewhat messy code. It is a rough format to go off of though.
int button = 0; //variable for button position
int previous = 0; //so it runs once for each button press
int n = 0; //incrementing variable
int first = 0; //variable to control the trim value
void setup()
{
Mouse.begin(); //begin, necessary
pinMode(10,INPUT); //I connected my switch between vcc and pin 10. I had a pulldown resistor from pin 10 to ground
}
void loop()
{
previous = button; //this is all to know if the button was pressed last check
button = digitalRead(10);
if(previous == 0 && button == 1) //if it was not pressed last, and is pressed now, the button was just pushed.
{
n++; //switches through the menu
switch(n) //each command under switch is a mouse movement and button press.
{
case 1: //move to car dealer and click
Mouse.move(-50,0,0);
Mouse.move(0,0,0);
delay(1000);
Mouse.move(0,-80,0);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
if(first == 1){ // only trim after the first run
Mouse.move(24,0,0);} //trim value
first = 1;
delay(1500);
button = 0; //remove all the button = 0; commands for testing if you don't want it to proceed without another button click.
break;
case 2: //move and click purchase cars
Mouse.move(0,-30,0);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
delay(2500);
button = 0;
break;
case 3: //move and click menu
Mouse.move(0,-30,0);
delay(100);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
delay(1000);
button = 0;
break;
case 4: //move and click gifts
Mouse.move(0,35,0);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
delay(500);
button = 0;
break;
case 5: //move and click buy
Mouse.move(20,75,0);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
delay(1000);
button = 0;
break;
case 6: //move and click yes, delay, then click okay
Mouse.move(130,0,0);
Mouse.move(0,0,0);
delay(100);
Mouse.move(0,-50,0);
Mouse.move(0,0,0);
delay(100);
Mouse.press();
Mouse.release();
delay(5000); //the internet is slowest here.
Mouse.move(1,0,0); //the okay button will not highlight unless you move it back and forth a little.
Mouse.move(0,0,0);
delay(100);
Mouse.move(-1,0,0);
Mouse.press();
Mouse.release();
Mouse.move(0,0,0);
delay(2000);
button = 0;
break;
case 7: // move to origin
for(n=0;n<10;n++){
Mouse.move(20,0,0);
Mouse.move(0,0,0);}
delay(100);
Mouse.move(17,0,0);
Mouse.move(0,0,0);
delay(500);
for(n=0;n<6;n++){
Mouse.move(0,20,0);
Mouse.move(0,0,0);}
delay(1000);
Mouse.move(0,0,0);
n = 0; //this makes it restart to the first case after it's done all 7.
button = 0;
break;
}
}
delay(10);
}