请问如何用delphi 模拟移动点击鼠标,

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请问如何用delphi 模拟移动点击鼠标,相关的知识,希望对你有一定的参考价值。

请问如何用delphi 模拟移动点击鼠标,实现后台的 并且要将这个delphi程序插入到需要点击的进程里

参考技术A 添加一个timer1控件+button1,将里面的代码全替换如下就可以了
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
Private declarations
public
Public declarations
end;

var
Form1: TForm1;
i:integer;//模拟按键时间
implementation

$R *.dfm

procedure TForm1.Button1Click(Sender: TObject);
begin
if Timer1.Enabled=true then
begin
i:=0;//清零
Timer1.Enabled:=false;
end
else
begin
i:=0;//清零
Timer1.Enabled:=true;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
i:=i+1;
if i mod 10=0 then
keybd_event($72,0,0,0);//$72是H键的虚拟键值,若要h健则是改为$48
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
i:=0;//初始化i
Timer1.Enabled:=false;
end;

end.
参考技术B 控制面板去设置

如何用selenium模拟鼠标操作

参考技术A selenium通过命令进行驱动,其中一种风格就是action(动作)。actions命令一般用于操作应用程序的状态,通过“点击”和“选择”的方式进行工作。webdriver继承了selenium中的actions类,这个actions类中,主要是模拟用户的鼠标mouse,键盘keyboard操作。对于这些操作,使用perform()方法进行执行。
对于前面说过的一些方法使用,涉及到鼠标键盘操作的,都可以使用actions类中的方法实现,比如:click,sendkeys。

Webdriver driver=new InternetExplorerDriver();
driver.get("http://www.baidu.com");

//新建一个action
Actions action=new Actions(driver);
//找到web元素:输入框,搜索按钮
WebElement inputWindow=driver.findElement(By.id("kw"));
WebElement searchButton=driver.findElement(By.id("su"));
action.sendKeys(inputWindow,"周韦彤").perform();
action.moveToElement(searchButton);
action.click().perform();
//上面的两条语句也可以这么写:action.click(serchButton)).perform();

以上是关于请问如何用delphi 模拟移动点击鼠标,的主要内容,如果未能解决你的问题,请参考以下文章

如何用c语言来实现鼠标移动。

请问如何用vbs实现获取屏幕某坐标颜色值!

如何用selenium模拟鼠标操作

如何用javascript点击指定的位置

delphi 后台模拟鼠标点击

如何用触摸数据模拟鼠标点击?