1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
void get_XY (long *pGT_X, long *pGT_Y, long *pScreen_Res_X, long *pScreen_Res_Y, int *pclick_function)
{
//DECLARE VARIABLES for function
bool flag = TRUE;
bool click = FALSE;
int click_counter = 0;
//DECLARATION OF VARIABLES for use in detecting automated click
long lower_x, lower_y, upper_x, upper_y;
//DECLARE pointers
long *plower_x = &lower_x;
long *plower_y = &lower_y;
long *pupper_x = &upper_x;
long *pupper_y = &upper_y;
//Setting lower and upper limit of cursor
//For X axis
if ( (*pGT_X -5) < 0 )
lower_x = 0;
else
lower_x = (*pGT_X - 5);//end else if
if ( (*pGT_X + 5) > *pScreen_Res_X )
upper_x = *pScreen_Res_X;
else
upper_x = (*pGT_X + 5);//end else if
//For Y axis
if ( (*pGT_Y -5) < 0 )
lower_y = 0;
else
lower_y = (*pGT_Y - 5);//end else if
if ( (*pGT_Y + 5) > *pScreen_Res_Y )
upper_y = *pScreen_Res_Y;
else
upper_y = (*pGT_Y + 5);//end else if
//End setting limits
printf ("\nStart: gt x %d, gt y %d, lower x %d, lower y %d, upper x %d, upper y %d\n", *pGT_X, *pGT_Y, *plower_x, *plower_y, *pupper_x, *pupper_y);
int n = 2; //sets the sampling rate before a click
for (int j = 0; j < n; ++j)
{
loop_for_control (pGT_X, pGT_Y, n);
if (check_position (pGT_X, pGT_Y, plower_x, plower_y, pupper_x, pupper_y))
{
++click_counter;
if (click_counter == n)
{
click = TRUE;
}
cout << "counter: " << click_counter << endl;
}
else
{
cout << "not same" << endl;
}
}
cout << *pclick_function << "click_function\n";
switch (*pclick_function)
{
case 1:
Left_click_once (*pGT_X, *pGT_Y);
cout << "\tLeft clicked\r";
break;
case 2:
Double_click (*pGT_X, *pGT_Y);
cout << "\tDouble clicked\r";
break;
default:
cout << "ERROR at clicking function\n";
break;
}
cout << "**********************************************\n";
}
| |