Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 7th, 2012  |  syntax: C  |  size: 0.67 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. int main()
  5. {
  6.     POINT p;
  7.     int lx = 0, ly = 0, lb = 0;
  8.     for (;;) {
  9.         GetCursorPos(&p);
  10.         // verifica se o mouse moveu
  11.         if ((p.x != lx) || (p.y != ly)) {
  12.             printf("%d,%d\n", p.x, p.y);
  13.             lx = p.x;
  14.             ly = p.y;
  15.         }
  16.         // verifica se o botão esquerdo foi pressionado,
  17.         // se estiver o bit mais significante é verdadeiro
  18.         if ((GetAsyncKeyState(VK_LBUTTON) & 0x8000))
  19.             printf("Botão esquerdo pressionado!\n");
  20.         if ((GetAsyncKeyState(VK_RBUTTON) & 0x8000))
  21.             printf("Botão direito pressionado!\n");
  22.     }
  23.     return 0;
  24. }