为了提高大家的安全意识,前段时间小王设计了一个蜜罐系统(详见《蜜罐系统正式开启》),为了让这个系统全自动,看起来很牛B,我用delphi写了两个小程序,一个是鼠标自动获得屏幕坐标的,一个是鼠标自动点击的,下图右侧是鼠标自动获得屏幕坐标的软件界面,今天把鼠标自动获得屏幕坐标的代码发出来。代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
p:TPoint;
begin
GetCursorPos(p);
Edit1.Text := IntToStr(p.X)+':'+IntToStr(p.Y);
end;
end.
用了两个控件,一个edit,一个timer,timer设置为1毫秒,相当于每1毫秒刷新一次坐标值。当初为了写这个程序费了不少周折,以为使用某个函数就可以了,没想到还要配合timer实现,最后还是在csdn发帖才解决的,希望对大家有帮助。
本文转自 小王 51CTO博客,原文链接:http://blog.51cto.com/xiaowang/531357,如需转载请自行联系原作者