Advertisement
Ansaid

Передвижение курсора мыши

Aug 10th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. /*Передвижение курсора мыши*/
  2. #include "pch.h"
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <windows.h>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.         int x = 0, y = 0; //начальные координаты
  12.         int step = 10;    //шаг передвижения
  13.         char c;
  14.  
  15.         SetCursorPos(x, y);
  16.         do {
  17.                 c = _getch();
  18.                 switch(c){
  19.                         case 75: SetCursorPos(x-=step, y); cout << "LEFT.\n"; break;
  20.                         case 77: SetCursorPos(x+=step, y); cout << "RIGHT.\n"; break;
  21.                         case 72: SetCursorPos(x, y-=step); cout << "UP.\n"; break;
  22.                         case 80: SetCursorPos(x, y+=step); cout << "DOWN.\n"; break;
  23.                 }
  24.         } while(c != 27); // Esc
  25.  
  26.         system("pause");
  27.         return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement