EvilZone

Programming and Scripting => C - C++ => : ca0s December 15, 2010, 08:46:36 PM

: [C] Autoclicker
: ca0s December 15, 2010, 08:46:36 PM
It is a simple tool I made a boring afternoon, playing some FB game...
Open it, enter number of clicks, then delay between each click, and press intro. You have 5 seconds to switch window and put your cursor in place.

:
#include <stdio.h>
#include <windows.h>

int getnum(int *result)
{                       
      char buff [ 13 ];
      return fgets(buff, sizeof buff, stdin) && sscanf(buff, "%d", result) == 1;
}

int main()
{
    printf("<<<<-- Ca0s Autoclicker -->>>>\n");
   
    printf("\n[-] Number of clicks: ");
    int clicks;
    do getnum(&clicks);
    while(!clicks);
   
    printf("\n[-] Delay between each click (0 allowed): ");
    int sleep;
    getnum(&sleep);
   
    printf("\n[+] Press INTRO to begin...");
    int charr;
    charr=fgetc(stdin);
    printf("\n[+] Clicks: %d ; Delay: %d", clicks, sleep);
    printf("\n[+] You have 5 seconds to change window and put cursor in place!\n");
    // Initial sleep...
    Sleep(5000);
    int i;
    for(i=0; i<clicks; i++)
    {
                           mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 1, 1, 1, 1);       // Left click
                           // mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 1, 1, 1, 1);  Right click
                           if(sleep)
                                    Sleep(sleep);
    }
    printf("[+] Finished.\n\n");
    charr=fgetc(stdin);
    return 0;
}
: Re: [C] Autoclicker
: Satan911 December 15, 2010, 08:52:25 PM
Not sure I get the getnum() function. Not really familiar with C (But I know C++) and can't you just use scanf (or something like that.. cin for C+) to get the number of clics and delay?
: Re: [C] Autoclicker
: ca0s December 15, 2010, 09:04:46 PM
Yes, you can use scanf. But scanf is an unsafe function that usually leads to buffer overflows.
Also, it was better to make a function, becouse I needed to check if there was input or not. So if it returns NULL, it is called again. That could have been made in the do-while, but I wanted to do it this way.
: Re: [C] Autoclicker
: Satan911 December 15, 2010, 10:29:15 PM
Alright I see. There are many little differences like this between C and C++ that make me not so comfortable with C.. thanks for your answer.
: Re: [C] Autoclicker
: Toxicgenie February 20, 2011, 07:27:11 AM
im getting the error of :

 fatal error: windows.h: No such file or directory
compilation terminated.
: Re: [C] Autoclicker
: ande February 20, 2011, 02:25:52 PM
im getting the error of :

 fatal error: windows.h: No such file or directory
compilation terminated.


What IDE or compiler are you using?
: Re: [C] Autoclicker
: virenderm01 March 26, 2011, 07:50:53 PM
check your header files dude and if your using turbo c compiler then check whether the directory address is correct where your tc is located ;) ;)
: Re: [C] Autoclicker
: I_Learning_I March 29, 2011, 04:09:26 PM
Nice script, quick and simple, although I must ask, what if I move the mouse a little? :S
You could got a getmouselocation() or whatever that is, would be only a few more lines, but would make it better :)
Anyhow +1 ;)

windows.h might not exist on *nix :O
: Re: [C] Autoclicker
: ca0s March 29, 2011, 08:06:37 PM
Nice script, quick and simple, although I must ask, what if I move the mouse a little? :S
You could got a getmouselocation() or whatever that is, would be only a few more lines, but would make it better :)
Anyhow +1 ;)

windows.h might not exist on *nix :O

Thanks!
Yes, if you move the mouse it will keep clicking wherever you move it.
And no, in *unix you won't have windows.h so no mouse_event() function.
: Re: [C] Autoclicker
: I_Learning_I March 30, 2011, 01:41:26 AM
Thanks!
Yes, if you move the mouse it will keep clicking wherever you move it.
And no, in *unix you won't have windows.h so no mouse_event() function.

Yea I know, was to Toxicgenie, I don't know where is he compiling, but perhaps hes in a linux distro and that's why.
Oh just another small hint I remembered, you could use GetAsynKeyState() and wait for a key to be pressed before it actually starts to work, like Press F9 to start.

:
if(GetAsyncKeyState(VK_F9)){
       click();
}

And satan what he could do was something like:
:
cin.getline(Var,maxofchars);
atoi(Var);