📄 unit2.pas
字号:
unit Unit2;
interface
uses Windows,Classes,unit1;
type
MOUSESIMU = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
delay,state:integer;
end;
var stop:boolean;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure MOUSESIMU.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ MOUSESIMU }
function CheckCursorPos():Boolean ;
begin
getcursorpos(p);
if (p.X<>cposx) or(p.Y<>cposy) then
CheckCursorPos:=false
else
CheckCursorPos:=true;
end;
procedure MOUSESIMU.Execute;
begin
if state=1 then
begin
repeat
setcursorpos(cposX,cposY);//锁定鼠标位置
if CheckCursorPos() then
begin
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//鼠标左键按下
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//鼠标左键放开
sleep(delay);//第二次鼠标按下的延时时间
end;
until stop;
end else
if state=2 then
begin
repeat
setcursorpos(cposX,cposY);//锁定鼠标位置
if CheckCursorPos() then
begin
mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); //鼠标右键键按下
mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);//鼠标右键放开
sleep(delay); //第二次鼠标按下的延时时间
end;
until stop;
end else
if state=3 then
begin
repeat
setcursorpos(cposX,cposY);//锁定鼠标位置
if CheckCursorPos() then
begin
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
sleep(delay); //第二次鼠标按下的延时时间
end;
until stop;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -