/*
Key to Mouse v0.1
Simulazione del comportamento del mouse tramite tastiera.
Autore: __GiReX__
Linguaggio: C
Data: 8/01/12
Os: Windows
Homepage: http://girex.altervista.org/
Per muovere il cursore del mouse tenere premuto [space]
più le freccette direzionali del numpad (Bloc Num: on)
Mouse sx click: [space] + NUMPAD 0
Mouse dx click: [space] + NUMPAD 3
[space] + [F12] per terminare l'esecuzione del programma
*/
#include <windows.h>
#include <stdio.h>
POINT coord; /* struct contenente le coordinate xy del mouse */
void left_click();
void right_click();
void move_up();
void move_down();
void move_left();
void move_right();
void start_prog()
{
MessageBox(NULL, "Key to Mouse v0.1 avviato come demone.\n" /* start message */
"Il programma rimarrà in background.\n"
"Si consiglia di leggere il file istruzioni.txt",
"Key To Mouse v0.1 by __GiReX__",
MB_OK);
HWND invisibile = FindWindow("ConsoleWindowClass", NULL); /* nascondo la finestra */
ShowWindow(invisibile, SW_HIDE);
}
int main()
{
start_prog();
while(!(GetAsyncKeyState(VK_SPACE) < 0 && GetAsyncKeyState(VK_F12) < 0))
{
if(GetAsyncKeyState(VK_SPACE) < 0)
{
if(GetAsyncKeyState(VK_NUMPAD0) < 0) left_click();
if(GetAsyncKeyState(VK_NUMPAD3) < 0) right_click();
if(GetAsyncKeyState(VK_NUMPAD8) < 0) move_up();
if(GetAsyncKeyState(VK_NUMPAD2) < 0) move_down();
if(GetAsyncKeyState(VK_NUMPAD6) < 0) move_right();
if(GetAsyncKeyState(VK_NUMPAD4) < 0) move_left();
}
Sleep(15);
}
return 0;
}
void left_click()
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
while(GetAsyncKeyState(VK_NUMPAD0) < 0)
{
if(GetAsyncKeyState(VK_SPACE) < 0)
{
if(GetAsyncKeyState(VK_NUMPAD8) < 0) move_up();
if(GetAsyncKeyState(VK_NUMPAD2) < 0) move_down();
if(GetAsyncKeyState(VK_NUMPAD6) < 0) move_right();
if(GetAsyncKeyState(VK_NUMPAD4) < 0) move_left();
}
Sleep(15);
}
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
void right_click()
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
Sleep(500);
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
}
void move_up()
{
GetCursorPos(&coord); /* prendo posizione mouse -> sposto */
SetCursorPos(coord.x, coord.y - 5);
}
void move_down()
{
GetCursorPos(&coord);
SetCursorPos(coord.x, coord.y + 5);
}
void move_right()
{
GetCursorPos(&coord);
SetCursorPos(coord.x + 5, coord.y);
}
void move_left()
{
GetCursorPos(&coord);
SetCursorPos(coord.x - 5, coord.y);
}