#include

#include

#include

#include

#include

class mouse

    {

    private:

    union REGS i,o;

    struct SREGS s;

    public:

    mouse()

        {

        initmouse();

        showmouseptr();

    }

    void initmouse()

        {

        i.x.ax=0;

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

    }

    void showmouseptr()

        {

        i.x.ax=1;

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

    }

    void getmousepos(int& button,int& x,int& y)

        {

        i.x.ax=3;

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

        button= o.x.bx;

        x=o.x.cx;

        y=o.x.dx;

    }

};

int x=0,y=0,button=0;

mouse m;

int controller=1;

struct btn

    {

     int bx1;

     int by1;

     int bx2;

     int by2;

};

void main()

    {

    // int gdriver = DETECT, gmode;

    // initgraph(&gdriver, &gmode, "\\borlan

    //     dc\\bgi");

     clrscr();

     gotoxy(2,2);

     cout<< "CLICK";

     btn b1 = {0,0,48,16};

     gotoxy(2,4);

     cout<< "CLICK";

     btn b2 ={0,16,48,32};

     gotoxy(2,6);

     cout<< "CLICK";

     btn b3 = {0,32,48,48};

     m.showmouseptr();

     while((!kbhit())&&(controller==1))

         {

         m.getmousepos(button,x,y);

         gotoxy(20,20);

         cout<< x << " " << y;

         if((x>b1.bx1)&&(y>b1.by1)&&(x

             {

             delay(300);

             gotoxy(12,12);

             cout << "You clicked #1";

             }

             else if((x>b2.bx1)&&(y>b2.by1)&&(x

                 {

                 delay(300);

                 gotoxy(12,12);

                 cout << "You clicked #2";

                 }

                 else if((x>b3.bx1)&&(y>b3.by1)&&(x

                     {

                     delay(300);

                     gotoxy(12,12);

                     cout<< "You clicked #3";

                     }

                     }

                }