Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Key to Mouse - key2mouse.c

key2mouse.c

Caricato da:
Scarica il programma completo

  1. /*
  2. Key to Mouse v0.1
  3. Simulazione del comportamento del mouse tramite tastiera.
  4.  
  5. Autore:         __GiReX__
  6. Linguaggio: C
  7. Data:           8/01/12
  8. Os:                     Windows
  9. Homepage:       http://girex.altervista.org/
  10.  
  11. Per muovere il cursore del mouse tenere premuto [space]
  12. più le freccette direzionali del numpad (Bloc Num: on)
  13.  
  14. Mouse sx click: [space] + NUMPAD 0
  15. Mouse dx click: [space] + NUMPAD 3
  16.  
  17.  
  18. [space] + [F12] per terminare l'esecuzione del programma
  19. */
  20.  
  21. #include <windows.h>
  22. #include <stdio.h>
  23.  
  24. POINT coord;        /* struct contenente le coordinate xy del mouse */
  25.  
  26. void left_click();
  27. void right_click();
  28. void move_up();
  29. void move_down();
  30. void move_left();
  31. void move_right();
  32.  
  33. void start_prog()
  34. {
  35.    MessageBox(NULL, "Key to Mouse v0.1 avviato come demone.\n"   /* start message */
  36.                     "Il programma rimarrà in background.\n"
  37.                     "Si consiglia di leggere il file istruzioni.txt",
  38.                     "Key To Mouse v0.1 by __GiReX__",
  39.               MB_OK);
  40.              
  41.    HWND invisibile = FindWindow("ConsoleWindowClass", NULL);     /* nascondo la finestra */
  42.    ShowWindow(invisibile, SW_HIDE);
  43.    
  44. }
  45.  
  46. int main()
  47. {
  48.   start_prog();
  49.  
  50.   while(!(GetAsyncKeyState(VK_SPACE) < 0 && GetAsyncKeyState(VK_F12) < 0))
  51.   {  
  52.    
  53.     if(GetAsyncKeyState(VK_SPACE) < 0)
  54.        {
  55.           if(GetAsyncKeyState(VK_NUMPAD0) < 0)    left_click();  
  56.           if(GetAsyncKeyState(VK_NUMPAD3) < 0)    right_click();
  57.           if(GetAsyncKeyState(VK_NUMPAD8) < 0)    move_up();
  58.           if(GetAsyncKeyState(VK_NUMPAD2) < 0)    move_down();
  59.           if(GetAsyncKeyState(VK_NUMPAD6) < 0)    move_right();
  60.           if(GetAsyncKeyState(VK_NUMPAD4) < 0)    move_left();
  61.        }        
  62.      Sleep(15);
  63.    }  
  64.        
  65.   return 0;
  66. }
  67.  
  68. void left_click()
  69. {
  70.    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
  71.    
  72.      while(GetAsyncKeyState(VK_NUMPAD0) < 0)
  73.        {
  74.          if(GetAsyncKeyState(VK_SPACE) < 0)
  75.             {
  76.                if(GetAsyncKeyState(VK_NUMPAD8) < 0)    move_up();
  77.                if(GetAsyncKeyState(VK_NUMPAD2) < 0)    move_down();
  78.                if(GetAsyncKeyState(VK_NUMPAD6) < 0)    move_right();
  79.                if(GetAsyncKeyState(VK_NUMPAD4) < 0)    move_left();
  80.             }        
  81.           Sleep(15);
  82.         }        
  83.                            
  84.    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  85. }
  86.  
  87. void right_click()
  88. {
  89.    mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
  90.      Sleep(500);
  91.    mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
  92. }
  93.  
  94. void move_up()
  95. {
  96.    GetCursorPos(&coord);                /* prendo posizione mouse -> sposto */
  97.    SetCursorPos(coord.x, coord.y - 5);
  98. }    
  99.  
  100. void move_down()
  101. {
  102.    GetCursorPos(&coord);
  103.    SetCursorPos(coord.x, coord.y + 5);
  104. }    
  105.  
  106. void move_right()
  107. {
  108.    GetCursorPos(&coord);
  109.    SetCursorPos(coord.x + 5, coord.y);
  110. }    
  111.  
  112. void move_left()
  113. {
  114.    GetCursorPos(&coord);
  115.    SetCursorPos(coord.x - 5, coord.y);
  116. }