Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls, Imglist, Comctrls, Extctrls;
Type
TForm1 = Class (Tform)
Button1:tbutton;
Edit1:tedit;
Button2:tbutton;
Button3:tbutton;
Button4:tbutton;
Timer1:ttimer;
Button6:tbutton;
Label1:tlabel;
Radiobutton1:tradiobutton;
Radiobutton2:tradiobutton;
Button5:tbutton;
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
Procedure Button3click (Sender:tobject);
Procedure Formmousemove (Sender:tobject; Shift:tshiftstate; X
Y:integer);
Procedure Button4click (Sender:tobject);
Procedure Timer1timer (Sender:tobject);
Procedure Button6click (Sender:tobject);
Procedure Button5click (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Procedure Tform1.button1click (Sender:tobject);
var pt:tpoint;
Begin
Simulate left-click
If Radiobutton1.checked Then
Begin
Pt:= Edit1.clienttoscreen (a point (bis)); Mouse positioning
Setcursorpos (Pt.x, PT.Y);
Mouse_event (mouseeventf_leftdown, 0, 0, 0, 0);
Mouse_event (mouseeventf_leftup, 0, 0, 0, 0);
End
Simulate right-click
If Radiobutton2.checked Then
Begin
Pt:= Edit1.clienttoscreen (a point (bis)); Mouse positioning
Setcursorpos (Pt.x, PT.Y);
Mouse_event (mouseeventf_rightdown, 0, 0, 0, 0);
Mouse_event (mouseeventf_rightup, 0, 0, 0, 0);
End
End
Procedure Tform1.button2click (Sender:tobject);
var btn3rect:trect;
Begin
Btn3rect: = Button3.boundsrect;
MapWindowPoints (handle,0, Btn3rect, 2); Coordinate conversion
Clipcursor (@btn3Rect); Limit Mouse Movement Area
End
Procedure Tform1.button3click (Sender:tobject);
var btscreen:trect;
Begin
Btscreen: = Rect (0, 0, screen.width, screen.height);
Clipcursor (@btScreen); Unlock to make the mouse active across the screen
End
Procedure Tform1.timer1timer (Sender:tobject);
Begin
Cursor:=crnone; 2 seconds to hide the mouse in the current form without moving the mouse
End
Procedure Tform1.formmousemove (Sender:tobject; Shift:tshiftstate; X
Y:integer);
Begin
If Timer1.enabled=true then//determine if the timer is open
Begin//If open, restart timing
Timer1.enabled:=false;
Timer1.enabled:=true;
End
Cursor:=crdefault; Change the cursor type to the default type when the mouse moves
End
Procedure Tform1.button6click (Sender:tobject);
var mouseinfo:string;
Begin
Detects if a mouse is installed
If (GetSystemMetrics (sm_mousepresent) <>0) Then
Mouseinfo:= ' 1. The system detects the mouse; '
Else mouseinfo:= ' 1. The system has no mouse; ';
Detects if the mouse supports sliding
If (GetSystemMetrics (sm_mousewheelpresent) <> 0) Then
Mouseinfo:=mouseinfo+ ' 2. The system supports sliding mouse. ‘
Else mouseinfo:=mouseinfo+ ' 2. The system does not support sliding the mouse. ‘;
Label1.caption:=mouseinfo;
End
Procedure Tform1.button4click (Sender:tobject);
Begin
Swapmousebutton (True); Swap around Keys
End
Procedure Tform1.button5click (Sender:tobject);
Begin
Swapmousebutton (False); Restore left and right keys
End
End.
Delphi Lock Mouse Simulation left and right key static one will automatically hide the mouse