Jump to content
Sign in to follow this  
Guest GoSu.SpeeD

[C/++] Cursor Movement

Recommended Posts

Guest GoSu.SpeeD

Well, since i noticed your guy's programming forum had no real programming, i decided to post up some small programs i have coded recently when bored.

I couldn't think of a better subject title for this one so i just gave it that one -.- basically, i was playing a game called World Of Kung Fu a while ago, and basically what happens is, for everyone hour you are online you get 5 points, and for every level you get, you get 20 points. You can use these points for a kind of afk-training type of thing. What happens is you go to an area of the game, open up the training menu, then you click "Online Training", once you do that you have to enter how many minutes you want to train for, if you set a number over the amount of minutes you have available it will just continue until your points are used. (by the way 1 point == 1 minute)

So, while you are sleeping you can use your points to gain exp through this training. Since you get points for every hour you're on, i coded this program to put myself into training mode every 15 minutes, so when i wake up i wouldn't have to use my minutes, they would be already used :)


#include <windows.h>
#include "keybd.h"

int CURSOR_X; // x-coordinate of mouse
int CURSOR_Y; // y-coordinate of mouse

int main()
    SetConsoleTitle("Qigong Training GoSu.SpeeD"); // Sets console title to whats in the quotes
    printf("Starting in 5 Seconds"); // prints to console, whatever is in quotes
    sleep(5000); // wait 5 seconds (measured in milliseconds)
    system("cls"); // Clear whatever text is printed in the console
    printf("Started, Commencing 300 Minutes of Training Every 15 Minutes");

    while(1)// enter infinite loop
        CURSOR_X = 729;
        CURSOR_Y = 507;
        SetCursorPos(CURSOR_X,CURSOR_Y); // Move cursor to specified co-ordinates
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); //LeftClick
        CURSOR_X = 631; // set the next point to click
        CURSOR_Y = 607;  
        SetCursorPos(CURSOR_X,CURSOR_Y); // move to that point
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); //LC
        CURSOR_X = 698; // set the next point to click
        CURSOR_Y = 450;
        SetCursorPos(CURSOR_X,CURSOR_Y); // move to that point (you get the point by now)
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 ); // LC
        keybd_event(THREE, 0, 0, 0); // type 3
        keybd_event(ZERO, 0, 0, 0); // type 0
        keybd_event(ZERO, 0, KEYEVENTF_KEYUP, 0); // simulated the key coming back up
        keybd_event(ZERO, 0, 0, 0); // 0 again
        keybd_event(ZERO, 0, KEYEVENTF_KEYUP, 0); // finally, return the key back up
        CURSOR_X = 690;
        CURSOR_Y = 485;
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
        CURSOR_X = 690;
        CURSOR_Y = 500;
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
        CURSOR_X = 729;
        CURSOR_Y = 507;
        mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0 );
        sleep(900000); // Wait 15 minutes
    return 0;

You may be wondering why i have to click so many places, well with this game it was like

1. Click online training

2. Click the text field, where you enter the number of minutes

3. Click the Accept button, after you enter your minutes

4. When you minutes are used up, notification pops up, so click that

also i have included a custom header file "keybd.h" which i made myself, i created it so that i could simulate keys easier, without having to know their hex codes, so instead of typing:

keybd_event(0x33, 0, 0, 0); (hex code for number 3 on keyboard)

i can type:

keybd_event(THREE, 0, 0, 0);

so here is the header file i created:


// Simulating Keys Simplified by GoSu.SpeeD

#define BACKSPACE 0x08
#define TAB 0x09
#define CLEAR 0x0C
#define ENTER 0x0D
#define SHIFT 0x10
#define CTRL 0x11
#define MENU 0x12
#define PAUSE 0x13
#define CAPS 0x14
#define ESC 0x1B
#define SPACE 0x20
#define ZERO 0x30
#define ONE 0x31
#define TWO 0x32
#define THREE 0x33
#define FOUR 0x34
#define FIVE 0x35
#define SIX 0x36
#define SEVEN 0x37
#define EIGHT 0x38
#define NINE 0x39
#define A 0x41
#define B 0x42
#define C 0x43
#define D 0x44
#define E 0x45
#define F 0x46
#define G 0x47
#define H 0x48
#define I 0x49
#define J 0x4A
#define K 0x4B
#define L 0x4C
#define M 0x4D
#define N 0x4E
#define O 0x4F
#define P 0x50
#define Q 0x51
#define R 0x52
#define S 0x53
#define T 0x54
#define U 0x55
#define V 0x56
#define W 0x57
#define X 0x58
#define Y 0x59
#define Z 0x5A
#define DOT 0xBE
#define ALT 0x12
#define DOWN 0x28
#define UP 0x26
#define RIGHT 0x27
#define LEFT 0x25
#define SLASH 0xBF
#define DASH 0xBD

to those who don't program, a define pretty much does what it means in english, by defining something, i can give it another name which can also be used instead of it's original name, so i do "#define NAME 123" which would mean, if i wanted to..........say place the integer value "123" in a INT type variable, i could type:

int number = NAME;

instead of: int number = 123;

but if i print the contents of the variable to the console, they would both give the same output. I planned to make this a pretty short post, so sorry if i dragged on :oops: even though you may never play this game, this will hopefully serve good as a reference on simulating keys, clicks and moving the cursor to specific co-ordinates :lol:

PS: To get the screen co-ordinates i had to create a separate program, which i will post up after this :)

Share this post

Link to post
Guest Jacob

I've looked up the game, its rather casuall korean mmo gameplay typically a leached idea from lineage. you got tons of games like that, there's to many to name. I like rpg's but i hate cheesy things like this.

@ the program, ok it basically runs and all... but thats just a really common macro. Practically you don't have to be a C guru to have a working script, there is a macro program wich perfectly does the job.

Wich i've used for eve online once as autominer aswell.

Share this post

Link to post
Guest Jacob
You should probably mention your programs are Windows specific.

#include <windows.h>

Nuff said...

Share this post

Link to post
Guest serdelus

Autohotkey is a program for writing macroes such as this. It has nice inteface and very good manual. You can make your own macros and compile them to exe files if you want. No need to depend on C. The widely used DotaKeys is written in Autohotkey ;)

The code could be much better if you split it into functions (with maybe half of the lines of code).

Share this post

Link to post
Sign in to follow this  

  • Create New...