tags:

views:

46

answers:

3

Hello,

I have a kind of funny and weird requirement this time. I have my account on Facebook and as you all know it is very popular for playing games. One of the applications that i came across was Click game in which a person has to click as many times as he can in span of 10 seconds. Well, one friend said he created some .Net code in C# that would automate the process of clicking on the button. Is it really possible or is he bluffing? If so, can anybody tell me how? I personally haven't seen him doing it. But he mentions this thing in front of my other friends. Any guidelines would be helpful. With much effort i clicked 92 times in 10 seconds and he said using some C# code he just kept a loop and clicked for 1500 times. Now i feel kind of inferior in front of him :p. Just 92 as against his 1500.

Thanks in advance :)

Even this code doesn't work. I can't see even a single click on my page made to facebook :-

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData,int dwExtraInfo);

        private const int MOUSEEVENTF_LEFTDOWN = 0x02;
        private const int MOUSEEVENTF_LEFTUP = 0x04;
        private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
        private const int MOUSEEVENTF_RIGHTUP = 0x10;


     public void DoMouseClick()
            {

                    int X = Cursor.Position.X;
                    int Y = Cursor.Position.Y;

                   for (int x = 0; x < 1000; x++)
                {
                    for (int y = 0; y < 600; y++)
                    {
                        mouse_event((uint)MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTDOWN, (uint)x, (uint)y, 0, 0);
                    }
                }


            }

Probably it doesn't work because mouse click is sent to OS not facebook.

+1  A: 

In .net, you can interact with the page scripts in a WebBrowser control with the InvokeScript API and interact with the page DOM via the Document property.

spender
You mean to say this is really possible? Hacking facebook games? This is kind of hacking only isn't it?
Ankit Rathod
+1  A: 

I've seen what you're talking about, and I, too, know people who have ridiculous numbers in that game. Most likely what they are doing is manipulating the JavaScript call that gets passed back to the server and relaying a fake number.

It is possible, however, to simulate a mouse click in .Net. Here's the code to trigger it:

[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;

public void DoMouseClick()
{
   int X = Cursor.Position.X;
   int Y = Cursor.Position.Y;
   mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
 }

As you can see, we're getting the X and Y positions from the mouse's current location; however, you can simulate a click anywhere on the screen so long as you know the coordinates.

If you run this code in a loop, and you get the X and Y coordinates of the button you're trying to press (possibly by delaying the click routine for a few seconds after execution so you have time to move your mouse to where the button is), you can accomplish what you're trying to do.

Note that I don't think this is how people are getting such large numbers in the game. Most likely you can edit the JavaScript calls via FireBug or similar developer tool and then send back fake data to the server.

rakuo15
Thanks rakuo, your answer is very informative. But can you tell me how do i edit the javascript? This is the link to the click game of facebook : http://apps.facebook.com/swdrfpaoqdordealf/?ref_6w=f_clicks . When i see in firebug it has lots of javascript. Do i need to go through them all to find out where they are sending the data?
Ankit Rathod
I don't want to add the app to my Facebook, so please excuse the fact that I can't help you find the JS you're looking for, specifically. But to answer your question, yes, that is what you would have to do. Most likely it's an AJAX request after the timer (that counts down for however many seconds you get) that gets made. Also, what you can try is in the function that gets executed when you click, instead of doing a `counter++;` or whatever it does, you can do a `counter = counter ^ counter;`, which would give you exponential growth. That's probably easier than messing with AJAX.
rakuo15
Your approach of C# doesn't work. Please see my edited post.
Ankit Rathod
A: 

A Test Framework like Selenium could used for such a challenge

chburd