Delphi mouse control function GetCursorPos, SetCursorPos

GetCursorPos function to get the position of the mouse

var 
   P: TPoint; 
the begin 
   GetCursorPos (P); // Get the mouse position 
end;

 

Function sets the mouse position SetCursorPos

var 
  X, Y: Integer; // 
the begin 
  X: = 614; Y: = 282; // 
  the SetCursorPos (X, Y); // 
  mouse_event (MOUSEEVENTF_LEFTDOWN, 0,0,0,0); // start clicking 
  mouse_event ( MOUSEEVENTF_LEFTUP, 0,0,0,0); // pop 
end;

 

Other operations:

var 
  the SDC: the HDC; 
  sColor: the COLORREF; 
the begin 
  // mouse moves to the coordinates X: 20 Y: 30 First 
  Mouse.CursorPos: = Point (20 is, 30); 

  // Get the screen coordinates X: 20 Y: First color of 30 
  the SDC : = the GetDC (0); 
  sColor: = the GetPixel (the SDC, 20 is, 30); 
  the ReleaseDC (0, the SDC); 

  // get the colors painted on the screen 
  Canvas.Brush.Color: = sColor; 
  Canvas.FillRect ( Rect (0, 0, 50, 50));

  

Guess you like

Origin www.cnblogs.com/guorongtao/p/11386720.html