2022-12-05 01:37:25 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <xdo.h>
|
|
|
|
|
|
|
|
#include "event.h"
|
|
|
|
#include "read_file.h"
|
|
|
|
|
2022-12-17 01:31:33 +00:00
|
|
|
args_readfile * args_rf_init(FILE *file, int time_sleep)
|
2022-12-05 02:07:23 +00:00
|
|
|
{
|
2022-12-17 01:31:33 +00:00
|
|
|
args_readfile *ret = (args_readfile *) malloc(sizeof(args_readfile));
|
|
|
|
ret->file = file;
|
|
|
|
ret->time_sleep = time_sleep;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void readfile(args_readfile *args)
|
|
|
|
{
|
|
|
|
FILE *file = args->file;
|
2022-12-05 01:37:25 +00:00
|
|
|
xdo_t *x_t = xdo_new(NULL);
|
|
|
|
|
|
|
|
event *current_event = new_event();
|
|
|
|
|
|
|
|
char left, right, middle;
|
|
|
|
short x, y;
|
|
|
|
|
|
|
|
while (!feof(file))
|
|
|
|
{
|
|
|
|
fread(current_event, sizeof(event), 1, file);
|
|
|
|
if (ferror(file))
|
|
|
|
{
|
2022-12-17 01:31:33 +00:00
|
|
|
fprintf(stderr, "Erreur à la lecture du fichier");
|
2022-12-05 01:37:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-12-19 14:21:03 +00:00
|
|
|
if (is_dummy(current_event)) continue;
|
|
|
|
|
2022-12-17 02:06:21 +00:00
|
|
|
left = (current_event->infos & M_LEFT) == M_LEFT;
|
2022-12-19 14:21:03 +00:00
|
|
|
right = (current_event->infos & M_RIGHT) == M_RIGHT;
|
|
|
|
middle = (current_event->infos & M_MIDDLE) == M_MIDDLE ;
|
2022-12-05 01:37:25 +00:00
|
|
|
|
|
|
|
x = current_event->x;
|
|
|
|
y = current_event->y;
|
|
|
|
|
|
|
|
xdo_move_mouse(x_t, x, y, 0);
|
|
|
|
|
|
|
|
if (left) xdo_click_window(x_t, CURRENTWINDOW, 1);
|
|
|
|
if (middle) xdo_click_window(x_t, CURRENTWINDOW, 2);
|
|
|
|
if (right) xdo_click_window(x_t, CURRENTWINDOW, 3);
|
|
|
|
|
2022-12-17 01:31:33 +00:00
|
|
|
sleep(args->time_sleep);
|
2022-12-05 01:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
free(current_event);
|
|
|
|
xdo_free(x_t);
|
|
|
|
}
|