Click here to Skip to main content
15,400,390 members
Articles / Desktop Programming / MFC
Posted 26 Jul 2007


48 bookmarked

Auto Clicker v1.0

Rate me:
Please Sign up or sign in to vote.
3.44/5 (11 votes)
9 Aug 2007CPOL2 min read
A program that clicks your mouse automatically.

Screenshot - Auto_Clicker.jpg


Auto Clicker is a program that clicks your mouse automatically. It allows the mouse to click without giving the user sore fingers. Just set the X-Y List using <SPACE> on your keyboard, set the click-interval, click the <start> button, and away from mouse and keyboard, it goes clicking the mouse automatically. For getting a faster auto-click speed, try setting the click interval to a lower number (milliseconds). To stop Auto Clicker, just press <ESC> on the keyboard. Auto Clicker can be used to make repetitive clicking easy, but should not be used to cheat in online-games. Auto Clicker is a freeware, easy to use, intuitive program, and the program source is open.

Using the Code

To build this program, you should know the mouse_event() function and hooking mechanism. From MSDN, you can know more about how the mouse_event() function synthesizes mouse motion and button clicks.

These are examples of using mouse_event() in this program:

mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, GetMessageExtraInfo()); // Left Key Down
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, GetMessageExtraInfo()); // Left Key UP

mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, GetMessageExtraInfo()); // Right Key Down
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, GetMessageExtraInfo()); // Right Key Up

To get keyboard messages when the application loses focus, you need hooking procedures.

In OnInitDialog(), SetWindowsHookEx() is used, and HookProc of SetWindowsHookEx is used as follows:

LRESULT CALLBACK HookMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
    HWND hwnd;
    LRESULT lResult = 0;
    if(nCode == HC_ACTION) 
        if(((EVENTMSG*)lParam)->message == VK_ESCAPE)
            hwnd= ::FindWindow(NULL, strProgName);
            return 1; 
        else if(((EVENTMSG*)lParam)->message == VK_PAUSE)
            hwnd=::FindWindow(NULL, strProgName);
            return 1; 

    return CallNextHookEx( hHook, nCode, wParam, lParam);

How to Use

First of all, you should fill the X-Y List box with the mouse points on the screen. Just move your mouse while pressing the <SPACE> key on the keyboard. While the Auto Clicker is working, if you want to stop it, just press the <ESC> key on the keyboard. If the [PAUSE] key on the keyboard is pressed, you can pause Auto Clicker. You can save the X-Y List to a file and later load it from the file using the <save> and <load> buttons.

Points of Interest

Does anybody know how to build this program without using the hooking mechanism?


This is my first article while I working for My latest article is available here.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Gordon W. Ahn
Web Developer
Korea (Republic of) Korea (Republic of)
I works at , This site provides Free Software Downloads and Pay-Per-Install Service .

Can you exchange website link with us?
You can submit yours to our resource page here

Comments and Discussions

QuestionCan you upload it again? Pin
Member 824288021-Sep-11 22:24
MemberMember 824288021-Sep-11 22:24 
GeneralNew feature request Pin
jadothebest12-Feb-09 4:17
Memberjadothebest12-Feb-09 4:17 
QuestionSave and load? V1.1? Pin
thejerm12-Feb-08 5:09
Memberthejerm12-Feb-08 5:09 
AnswerRe: Save and load? V1.1? Pin
[deco]7-Apr-08 8:53
Member[deco]7-Apr-08 8:53 
AnswerAnother version 1.5 Pin
[deco]7-Apr-08 8:57
Member[deco]7-Apr-08 8:57 
GeneralRe: Another version 1.5 Pin
thejerm8-Apr-08 20:25
Memberthejerm8-Apr-08 20:25 
GeneralRe: Another version 1.5 Pin
[deco]10-Apr-08 0:41
Member[deco]10-Apr-08 0:41 
GeneralRe: Another version 1.5 Pin
thejerm10-Apr-08 1:02
Memberthejerm10-Apr-08 1:02 
GeneralRe: Another version 1.5 Pin
[deco]10-Apr-08 1:47
Member[deco]10-Apr-08 1:47 
GeneralRe: Another version 1.5 Pin
thejerm10-Apr-08 3:10
Memberthejerm10-Apr-08 3:10 
GeneralRe: Another version 1.5 Pin
vitttt1117-Jan-09 22:10
Membervitttt1117-Jan-09 22:10 
GeneralA similar app has been around for years Pin
valex12327-Jul-07 13:04
Membervalex12327-Jul-07 13:04 
GeneralRe: A similar app has been around for years Pin
Gordon W. Ahn27-Jul-07 21:10
MemberGordon W. Ahn27-Jul-07 21:10 
Questionwhat about... Pin
toxcct26-Jul-07 3:18
Membertoxcct26-Jul-07 3:18 
AnswerRe: what about... Pin
Gorden26-Jul-07 18:01
MemberGorden26-Jul-07 18:01 
AnswerRe: what about... Pin
Cetin Yilmaz9-Aug-07 19:41
MemberCetin Yilmaz9-Aug-07 19:41 
Generalwhat if... Pin
toxcct9-Aug-07 21:18
Membertoxcct9-Aug-07 21:18 
AnswerRe: what about... Pin
Gordon W. Ahn10-Aug-07 21:57
MemberGordon W. Ahn10-Aug-07 21:57 
GeneralRe: what about... Pin
HerNone11-Aug-07 5:08
MemberHerNone11-Aug-07 5:08 
GeneralRe: what about... Pin
HerNone14-Aug-07 2:35
MemberHerNone14-Aug-07 2:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.