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

[C/++] Get Co-ords

Recommended Posts

Guest GoSu.SpeeD

This is a simple program i made, in conjunction with the "Qigong Training" tool, i had to first get the co-ordinates of the buttons in-game, for which i made this, when you have this program running, it will print the current XY co-ordinates of your cursor, when you press CTRL + E, shown in the screenshot below:

2j48vvm.png

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

POINT pos;
int x;
int y;

int main()
{
    while(1)
    {      
        sleep(20);/* wait 20ms between each loop
                     we do this to reduce computer stress */
        
        // if the user presses CTRL + E            
        if (GetAsyncKeyState(CTRL) &0x8000 && GetAsyncKeyState(E) &0x8000)
        {
            GetCursorPos(&pos); // get current cursor position, store it our point structure "pos"
            x = pos.x; // retrieve the x co-ordinate from "pos", place it in the int variable "x"
            y = pos.y; // retrieve the y co-ordinate from "pos" place it in the int variable "y"
            printf("X: %d Y: %d\n", x, y); // print the contents of "x" and "y" which is our co-ordinates :)
            sleep(1000); // wait 1 second
        }
    }
    getchar(); // Pause    
    return 0; // exit
}

the "keybd" header file can be found in my cursor movement post:

viewtopic.php?f=10&t=1259

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...