Mouse Interaction using C/C++

Hi everyone…

Following is the headerfile contains functions to interact with mouse. I took the hint from “Let Us C”.

#include <dos.h>

union REGS i,o;

int86 (0x33,&i,&o);

void ShowMousePointer()
int86 (0x33,&i,&o);

void GetPositionAndButton(int *button, int *x, int *y)
int86 (0x33,&i,&o);

void HideMousePointer()
int86 (0x33,&i,&o);

1. call the InitMouse() function to initialize. (Once required)
2. Call the function ShowMousePointer() to make the pointer appear in your application.
3. The function GetPositionAndButton will return the current mouse pointer location in terms of x & y coordinate and the button status, i.e., left or right etc..
4. You can hide your mouse pointer by calling HideMousePointer function.

Now you can capture the mouse activities using following loop.

while (!kbhit())
getmousepos (&button,&x,&y);
gotoxy (5,3);
(button &1)== 1 ? printf (“Left Down”): printf (“Left UP”);
gotoxy (20,3);
(button &2 )==2 ? printf (“Rigt Down”): printf (“Right UP”);
gotoxy (1,1);
printf (“x = %3d, y = %3d”,x,y);

5. Thats it.

Keep Smiling 🙂


2 Responses to “Mouse Interaction using C/C++”

  1. Mouse Says:


    yeah thats what I ment, i didnt remember the spelling but i did remember the meaning of the Mouse

  2. A3 Says:

    Thanks so much
    u saved my life man
    thanks again

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: