can you please tell how you would invert the mouse control so that up is down, left is right etc.

can you please tell how you would invert the mouse control so that up is down, left is right etc.

You don't need any hook (!)
Simply use Win32 System apis (2 lines of code to swap mouse buttons...)

Comments
no

You don't need any hook (!)
Simply use Win32 System apis (2 lines of code to swap mouse buttons...)

hey can u pls explain me how exactly to invert it??...what lines to change and all??....thanks in advance

Working program

#include <windows.h>

void getcoords(int &x, int &y) {
POINT cursorPos;
        GetCursorPos(&cursorPos);
        x = cursorPos.x;
        y = cursorPos.y;
        }

int main() {
    int x,y;
    int x2,y2;
    int dx,dy;

    while(true) {

    getcoords(x,y);
    Sleep(30);
    getcoords(x2,y2);

    dx = x2 - x;
    dy = y2 - y;
    SetCursorPos(x-dx,y-dy);
    }

return 0;
}

To make the program work more smoothly decrease the Sleep() time

Now it works for top 2 corners but not for the buttom 2 corners, I am not sure why

#include <windows.h>
#include <iostream>

void getcoords(int &x, int &y);

bool equals(int n1, int n2);

using namespace std;

int main() {
    int x,y; //first x and y
    int x2,y2; //second x and y
    int dx,dy; //difference

SetCursorPos(9999,9999);
int mx,my; //max x and max y on the particular screen
getcoords(mx,my);

SetCursorPos(-50,-50);
int minx,miny;
getcoords(minx,miny);

 //   int g;
// std::cin >> g;

    while(true) {
getcoords(x,y);
    Sleep(3);
getcoords(x2,y2);



if(equals(x,mx)) {
x = x-2;
}

if(equals(x2,mx)) {
x2 = x2-2;
}

if(equals(y2,mx)) {
y2 = y2-2;
}

if(equals(y,mx)) {
y = y-2;
}









if(equals(x,minx)) {
x = x+2;
}

if(equals(x2,minx)) {
x2 = x2+2;
}

if(equals(y2,minx)) {
y2 = y2+2;
}

if(equals(y,minx)) {
y = y+2;
}


SetCursorPos(x2,y2);

    dx = x2 - x;
    dy = y2 - y;
    SetCursorPos(x-dx,y-dy);
    }


return 0;
}


bool equals(int n1, int n2) {
if(abs(n1-n2) < 3) {
return true;
}
else {
return false;
}

   }

void getcoords(int &x, int &y) {
POINT cursorPos;
        GetCursorPos(&cursorPos);
        x = cursorPos.x;
        y = cursorPos.y;
        }

LOL I made a stupid mistake last time. THis works perfectly. Increasing Sleep(); makes the computer use less resources but it makes the program less smoother. So if you need really smooth mouse decrease sleep and if you dont wont to take much computer resources increase sleep

#include <windows.h>
#include <iostream>

void getcoords(int &x, int &y);

bool equals(int n1, int n2);

using namespace std;

int main() {
    int x,y; //first x and y
    int x2,y2; //second x and y
    int dx,dy; //difference

SetCursorPos(-50,-50);
int minx,miny;
getcoords(minx,miny);

SetCursorPos(9999,9999);
int mx,my; //max x and max y on the particular screen
getcoords(mx,my);



 //   int g;
// std::cin >> g;

    while(true) {
getcoords(x,y);
    Sleep(3);
getcoords(x2,y2);



if(equals(x,mx)) {
x = x-2;
}

if(equals(x2,mx)) {
x2 = x2-2;
}

if(equals(y2,my)) {
y2 = y2-2;
}

if(equals(y,my)) {
y = y-2;
}









if(equals(x,minx)) {
x = x+2;
}

if(equals(x2,minx)) {
x2 = x2+2;
}

if(equals(y2,miny)) {
y2 = y2+2;
}

if(equals(y,miny)) {
y = y+2;
}


SetCursorPos(x2,y2);

    dx = x2 - x;
    dy = y2 - y;
    SetCursorPos(x-dx,y-dy);
    }


return 0;
}


bool equals(int n1, int n2) {
if(abs(n1-n2) < 3) {
return true;
}
else {
return false;
}

   }

void getcoords(int &x, int &y) {
POINT cursorPos;
        GetCursorPos(&cursorPos);
        x = cursorPos.x;
        y = cursorPos.y;
        }

LOL I made a stupid mistake last time. THis works perfectly. Increasing Sleep(); makes the computer use less resources but it makes the program less smoother. So if you need really smooth mouse decrease sleep and if you dont wont to take much computer resources increase sleep

#include <windows.h>
#include <iostream>

void getcoords(int &x, int &y);

bool equals(int n1, int n2);

using namespace std;

int main() {
    int x,y; //first x and y
    int x2,y2; //second x and y
    int dx,dy; //difference

SetCursorPos(-50,-50);
int minx,miny;
getcoords(minx,miny);

SetCursorPos(9999,9999);
int mx,my; //max x and max y on the particular screen
getcoords(mx,my);



 //   int g;
// std::cin >> g;

    while(true) {
getcoords(x,y);
    Sleep(3);
getcoords(x2,y2);



if(equals(x,mx)) {
x = x-2;
}

if(equals(x2,mx)) {
x2 = x2-2;
}

if(equals(y2,my)) {
y2 = y2-2;
}

if(equals(y,my)) {
y = y-2;
}









if(equals(x,minx)) {
x = x+2;
}

if(equals(x2,minx)) {
x2 = x2+2;
}

if(equals(y2,miny)) {
y2 = y2+2;
}

if(equals(y,miny)) {
y = y+2;
}


SetCursorPos(x2,y2);

    dx = x2 - x;
    dy = y2 - y;
    SetCursorPos(x-dx,y-dy);
    }


return 0;
}


bool equals(int n1, int n2) {
if(abs(n1-n2) < 3) {
return true;
}
else {
return false;
}

   }

void getcoords(int &x, int &y) {
POINT cursorPos;
        GetCursorPos(&cursorPos);
        x = cursorPos.x;
        y = cursorPos.y;
        }

hey thnx a lot...dis inverts both x,y axis...cn u gimme code for y-axis alone..thnx a lot again...n does this work inside a game also???

I dont think it will work in games :( For that there is probably DirectX3D or DirectX Input functions. I am studying game programming myself right now

To inverse 1 axis you just have to change minus sign to plus

#include <windows.h>
#include <iostream>

void getcoords(int &x, int &y);

bool equals(int n1, int n2);

using namespace std;

int main() {
    int x,y; //first x and y
    int x2,y2; //second x and y
    int dx,dy; //difference

SetCursorPos(-50,-50);
int minx,miny;
getcoords(minx,miny);

SetCursorPos(9999,9999);
int mx,my; //max x and max y on the particular screen
getcoords(mx,my);



 //   int g;
// std::cin >> g;

    while(true) {
getcoords(x,y);
    Sleep(3);
getcoords(x2,y2);



if(equals(x,mx)) {
x = x-2;
}

if(equals(x2,mx)) {
x2 = x2-2;
}

if(equals(y2,my)) {
y2 = y2-2;
}

if(equals(y,my)) {
y = y-2;
}









if(equals(x,minx)) {
x = x+2;
}

if(equals(x2,minx)) {
x2 = x2+2;
}

if(equals(y2,miny)) {
y2 = y2+2;
}

if(equals(y,miny)) {
y = y+2;
}


SetCursorPos(x2,y2);

    dx = x2 - x;
    dy = y2 - y;
    SetCursorPos(x-dx,y-dy); ///CHANGE THIS from minus to plus to inverse
    } //different axises


return 0;
}


bool equals(int n1, int n2) {
if(abs(n1-n2) < 3) {
return true;
}
else {
return false;
}

   }

void getcoords(int &x, int &y) {
POINT cursorPos;
        GetCursorPos(&cursorPos);
        x = cursorPos.x;
        y = cursorPos.y;
        }

So you can change from
SetCursorPos(x-dx,y-dy)
to SetCursorPos(x+dx,y-dy) or
SetCursorPos(x-dx,y+dy)
If you keep both of them + then the mouse will act normal

This article has been dead for over six months. Start a new discussion instead.