PhotoShaman

Движение курсора консоли мышью

Dec 7th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. HWND GetConsoleHwnd()
  2. {
  3. #define MY_BUFSIZE 1024
  4.     HWND hwndFound;
  5.     char pszNewWindowTitle[MY_BUFSIZE];
  6.     char pszOldWindowTitle[MY_BUFSIZE];
  7.     GetConsoleTitle((LPWSTR)pszOldWindowTitle, MY_BUFSIZE);
  8.     SetConsoleTitle((LPWSTR)pszNewWindowTitle);
  9.     Sleep(1);
  10.     hwndFound = FindWindow(NULL, (LPWSTR)pszNewWindowTitle);
  11.     SetConsoleTitle((LPWSTR)pszOldWindowTitle);
  12.     return(hwndFound);
  13. }
  14. .....
  15. void MoveCursor()
  16. {
  17.  
  18. int xPos, yPos;
  19.     RECT r;
  20.     POINT p;
  21.     HWND wh = GetConsoleHwnd();
  22.     COORD c = { 1,1 };
  23.     while (true)
  24.     {
  25.         GetWindowRect(wh, &r);
  26.         GetCursorPos(&p);
  27.         if (IsWindows8OrGreater()) yPos = (p.y - r.top - 30) / 16; //Координаты Y для вин8-10
  28.         else yPos = (p.y - r.top - 30) / 12; //Координаты Y для вин7
  29.         xPos = (p.x - r.left - 9) / 8; //Координаты X для вин7 и вин10
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment