I want to detect if mouse moved in 5 seconds, if yes time elapsed is showed. Here is my code, it seems ok but doesn’t work correctly.
void timer()
{
if (ismouseclick(WM_MOUSEMOVE))
{
movetime=clock();
clearmouseclick(WM_MOUSEMOVE);
}
if ((clock()-movetime)<6)
{
sprintf(time_str,"%d",clock();
outtextxy(275,483,"Time: ");
outtextxy(340,483,time_str);
}
else
{
setfillstyle(1,0);
bar(275,483,370,500);
}
}
Its about clock() function. You need to divide it to CLK_TCK (a constant) if you want seconds.