codice:
#include <windows.h>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <winable.h>
int x=100;
int y=100;
int i=0;
int a=0;
int left_click()
{
// left mouse button down
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1,&Input,sizeof(INPUT));
// left mouse button up
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1,&Input,sizeof(INPUT));
}
int right_click()
{
// right mouse button down
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
::SendInput(1,&Input,sizeof(INPUT));
// right mouse button up
::ZeroMemory(&Input,sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
::SendInput(1,&Input,sizeof(INPUT));
}
void controlla_tastiera(){
if (GetAsyncKeyState(37)) {
x-=10;
SetCursorPos(x,y);
}
if (GetAsyncKeyState(38)) {
y-=20;
SetCursorPos(x,y);
}
if (GetAsyncKeyState(39)) {
x+=10;
SetCursorPos(x,y);
}
if (GetAsyncKeyState(40)) {
y+=20;
SetCursorPos(x,y);
}
//left click tasto PAUSE
if(GetAsyncKeyState(45)==-32767){
left_click();
}
}
int main() {
while(1){
controlla_tastiera();
Sleep(30);}
}
ti posto la mia soluzione
ovviamente cambiando i keycode puoi cambiare i tasti di controllo, se qlc non è chiaro dimmi
(il tasto dx non ha il suo tasto, ma credo che il codice sia più che banale da modificare per usarlo )