46 lines
872 B
C
46 lines
872 B
C
//#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <xdo.h>
|
|
|
|
#include "event.h"
|
|
#include "read_file.h"
|
|
|
|
void readfile(FILE *file) {
|
|
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))
|
|
{
|
|
printf("Erreur !!");
|
|
break;
|
|
}
|
|
|
|
left = current_event->infos & LEFT;
|
|
right = current_event->infos & RIGHT;
|
|
middle = current_event->infos & MIDDLE;
|
|
|
|
x = current_event->x;
|
|
y = current_event->y;
|
|
|
|
xdo_move_mouse(x_t, x, y, 0);
|
|
sleep(1);
|
|
|
|
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);
|
|
|
|
sleep(5);
|
|
}
|
|
|
|
free(current_event);
|
|
xdo_free(x_t);
|
|
}
|