g3x0

Draw and move pointer with keyboard arrows

Dec 9th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. int main() {
  4.     POINT p;
  5.     int speed = 2;
  6.    
  7.     HWND asd = GetDesktopWindow();
  8.     HDC aaa = GetDC(asd);
  9.    
  10.     COLORREF clr = RGB(0,0,250);
  11.    
  12.     while (true) {
  13.         GetCursorPos(&p);
  14.        
  15.         if(GetAsyncKeyState(VK_LEFT))
  16.             p.x -= speed;
  17.         if(GetAsyncKeyState(VK_RIGHT))
  18.             p.x += speed;
  19.         if(GetAsyncKeyState(VK_UP))
  20.             p.y -= speed;
  21.         if(GetAsyncKeyState(VK_DOWN))
  22.             p.y += speed;
  23.         if(GetAsyncKeyState(VK_END))
  24.             break;
  25.         if(GetAsyncKeyState(VK_NEXT)) {
  26.             //mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
  27.             SetPixel(aaa, p.x, p.y, clr);
  28.             SetPixel(aaa, p.x+1, p.y+1, clr);
  29.         }
  30.         if(GetAsyncKeyState(VK_NUMPAD1))
  31.             clr = RGB(0,255,0);
  32.         if(GetAsyncKeyState(VK_NUMPAD2))
  33.             clr = RGB(255,0,0);
  34.         if(GetAsyncKeyState(VK_NUMPAD3))
  35.             clr = RGB(150,0,100);
  36.        
  37.         SetCursorPos(p.x, p.y);
  38.         Sleep(3);
  39.     }
  40.    
  41.     return 0;
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment