This is a C program to implement mouse co-ordinates as well as status of button click in the hardware lab.
If you have any doubts, please let me know.
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int x,y , z,x1,y1,z1;
union REGS in,out;
in.x.ax=1;
int86(0x33,&in,&out);
in.x.ax=3;
int86(0x33,&in,&out);
x1=out.x.cx;
y1=out.x.dx;
z1=out.x.bx;
do
{
do
{
in.x.ax=1;
int86(0x33,&in,&out);
in.x.ax=3;
int86(0x33,&in,&out);
x=out.x.cx;
y=out.x.dx;
z=out.x.bx;
}while((x==x1)&&(y==y1)&&(z==z1));
clrscr();
printf("MOUSE
COORDINATES:");
printf("\nx
coordinate:%d\t ",x1);
printf("\ny
coordinate:%d\t ",y1);
printf("\n\nBUTTON
STATUS");
switch(z1)
{
case 0: printf("\nNo press\n");
break;
case
1:printf("\nLeft press\n");
break;
case 2:printf("\nRight
press\n");
break;
case 3:printf("\nBoth press\n");
break;
}
x1=x;
y1=y;
z1=z;
printf("\n\nPress any key to
exit..");
}while(!kbhit());
in.x.ax=2;
int86(0x33,&in,&out);
}
No comments:
Post a Comment