Saturday 20 December 2014

C# : Simple hack script for games with repeated pressing of same keys in order.


There are lot of simple games available online which are basically not strategic, but just require one key to play or set of keys to be pressed in order repeatedly in order to score the maximum point.
For example you can take
http://playtap.in/ where we have to press Spacebar repeatedly, or
http://gabrielecirulli.github.io/2048/ where the Right Arrow and the Down Arrow is pressed repeatedly etc.

For these games we can do a simple hack using C# SendKeys class .

How to implement 

Just create a small GUI with START and STOP buttons . A demo GUI is given below.


Inside the START button's click method run a loop n times for the set of keys to be pressed.
(here START button is btnStart )

 private void btnStart_Click(object sender, EventArgs e)
 {
     //Here n is the no. of times you want to run the loop
     for(int i = 0; i < N ; i++)
     {
         //SendKeys.Send("wsad");  this method can be used to press 'w'
         //'s' 'a' and 'd' , N no. of times in same order
         SendKeys.Send(" "); //for sending spacebar
     }
 }
NOTE : For more information regarding SendKeys visit SendKeys.send();

No comments:

Post a Comment