using turboc++
-----------------------------------------------------------------------------------------------------
//program to detect button on click
#include <dos.h>
#include<stdio.h>
#include<conio.h>
union REGS in_put, out_put;// input and output variables stored in union
//input for signal detection;output for screen display
void mouse_detected ()
{
in_put.x.ax = 0;// ax is register used for mouse
int86 (0X33,&in_put,&out_put); //invokes interrupt using 0X33; for mouse, it is 0X33
if (out_put.x.ax == 0) //condition testing
printf("\nMouse Failed To Initialize");
else
printf ("\nMouse was Succesfully Initialized");
//initialization on screen
}
void show_mouse()
{
in_put.x.ax = 1; //1 is to display mouse
int86(0X33,&in_put,&out_put); //interrupt invoked
}
void mouse_bttn()
{
while(!kbhit()) //until a keystroke is pressed
{
int x,y;
in_put.x.ax=3; //3 is for co-ordinate value
int86 (0X33,&in_put,&out_put);
if (out_put.x.bx == 1) //1 for left click
printf ("\nLeft clicked");
else if (out_put.x.bx == 2) //2 for right click
printf ("\nRight clicked");
else if (out_put.x.bx == 3)//3 for wheel click
printf ("\nMiddle clicked");
delay (200); // Otherwise due to quick computer response 100s of words will get print
}
}
int main ()
{
mouse_detected ();//calling of function
show_mouse();//calling of function
mouse_bttn();
getch ();
return 0;
}
-----------------------------------------------------------------------------------------------------
//program to detect button on click
#include <dos.h>
#include<stdio.h>
#include<conio.h>
union REGS in_put, out_put;// input and output variables stored in union
//input for signal detection;output for screen display
void mouse_detected ()
{
in_put.x.ax = 0;// ax is register used for mouse
int86 (0X33,&in_put,&out_put); //invokes interrupt using 0X33; for mouse, it is 0X33
if (out_put.x.ax == 0) //condition testing
printf("\nMouse Failed To Initialize");
else
printf ("\nMouse was Succesfully Initialized");
//initialization on screen
}
void show_mouse()
{
in_put.x.ax = 1; //1 is to display mouse
int86(0X33,&in_put,&out_put); //interrupt invoked
}
void mouse_bttn()
{
while(!kbhit()) //until a keystroke is pressed
{
int x,y;
in_put.x.ax=3; //3 is for co-ordinate value
int86 (0X33,&in_put,&out_put);
if (out_put.x.bx == 1) //1 for left click
printf ("\nLeft clicked");
else if (out_put.x.bx == 2) //2 for right click
printf ("\nRight clicked");
else if (out_put.x.bx == 3)//3 for wheel click
printf ("\nMiddle clicked");
delay (200); // Otherwise due to quick computer response 100s of words will get print
}
}
int main ()
{
mouse_detected ();//calling of function
show_mouse();//calling of function
mouse_bttn();
getch ();
return 0;
}