Is there a way to have mouse clicks in a console app? While I'm sure, almost positive that there is a way, can someone show me an example of how to, if said action is possible. And while I don't want to sound like a beggar, it would also help me heaps if someone could whip up a sample app that would send certain messages if a mouse click in the right place happened. I would greatly appreciate it.
if (Gpm_Open(&conn,0)==-1)
{
printf("Can not open mouse connection\n");
exit(1);
}
while(1)
{
FD_ZERO(&readset);
FD_SET(gpm_fd,&readset);
select(gpm_fd+1,&readset,0,0,0);
if (FD_ISSET(gpm_fd,&readset))
{
if (Gpm_GetEvent(&event)>0)
{
printf("mouse: event 0x%02X, at %2i %2i (delta %2i %2i),"
"button %i, modifiers 0x%02X\r\n",
event.type,
event.x,event.y,
event.dx,event.dy,
event.buttons,
event.modifiers
);
}
}
}
while (Gpm_Close());
}
[root@admin shm]# c++ test.cpp -lgpm
[root@admin shm]# ./a.out
mouse: event 0x01, at 40 12 (delta 0 0),button 0, modifiers 0x00
PS: you must sure if the gpm service is running by 'service gpm status' command, or you may encounter the following errors:
[root@admin shm]# ./a.out
*** info [lib/liblow.c(329)]:
/dev/gpmctl: No such file or directory
*** err [lib/liblow.c(336)]:
/dev/gpmctl: No such file or directory
Can not open mouse connection
Does this require a library? Or is it because I'm on Windows? I got the following errors:
Line 4; error: gpm.h: No such file or directory
Line 8; error: 'fd set' was not declared in this scope