title: How to Get Mouse Cursor Cordinates when left click is pressed and when left click is released in C++?
body: <p>I am trying to create snipping tool for college project I am trying to work on: where user can take screenshot of area mouse covered and stretched while clicked.</p>
  
  <p>For example : When left mouse is clicked : It gets cordinates x,y axis and when mouse is released it gets x,y axis. I cannot find any code or event function in SendInput() as well. Help.</p>
  
  <p>For creating screenshot and adding into Clipboard I am using this code : </p>
  
  <pre><code>void screenshot(POINT a, POINT b)
  {
      // copy screen to bitmap
      HDC     hScreen = GetDC(NULL);
      HDC     hDC = CreateCompatibleDC(hScreen);
      HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, abs(b.x - a.x), abs(b.y - a.y));
      HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
      BOOL    bRet = BitBlt(hDC, 0, 0, abs(b.x - a.x), abs(b.y - a.y), hScreen, a.x, a.y, SRCCOPY);
  
  
  
      // save bitmap to clipboard
      OpenClipboard(NULL);
      EmptyClipboard();
      SetClipboardData(CF_BITMAP, hBitmap);
      CloseClipboard();
  
      // clean up
      SelectObject(hDC, old_obj);
      DeleteDC(hDC);
      ReleaseDC(NULL, hScreen);
      DeleteObject(hBitmap);
  }
  
  int main()
  {
      POINT a, b;
      a.x = 0;
      a.y = 0;
  
      b.x = 10000;
      b.y = 10000;
  
      screenshot(a, b);
  }
  </code></pre>