Delphi中Chrome Chromium、Cef3学习笔记(五)

 

一、模拟移动鼠标

//  SetCursorPos(StrToInt(Edit1.Text),StrToInt(Edit2.Text));  //相对屏幕位置
  SetCursorPos(Self.Left+chrm1.Left+strtoint(Edit1.Text),Self.Top+chrm1.Top+strtoint(Edit2.Text));  //相对Chrm位置

 

       mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//模拟按下鼠标左键。

  mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//模拟放开鼠标左键。


  keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),0,0); //按下SHIFT键。
  keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//按下R键。
  keybd_event(0x52,MapVirtualKey(0x52,0),KEYEVENTF_KEYUP,0);//放开R键。
  keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP,0);//放开SHIFT键。

 

二、Chromiume控件指定坐标点击

  SendMessage(GetWindow(GetWindow(form1.chrm1.Handle, GW_CHILD), GW_CHILD),WM_LBUTTONDOWN,MK_LBUTTON, MAKELONG(StrToIntDef(Edit1.Text,100),StrToIntDef(Edit2.Text,100))); 

  SendMessage(GetWindow(GetWindow(form1.chrm1.Handle, GW_CHILD), GW_CHILD),WM_LBUTTONUP,MK_LBUTTON, MAKELONG(StrToIntDef(Edit1.Text,100),StrToIntDef(Edit2.Text,100)));

 

MK_LBUTTON可以改为0,MAKELONG可以改为MAKELParam

 

 

三、JS控制滚动条的位置:
window.scrollTo(x,y);

竖向滚动条置顶(window.scrollTo(0,0);
竖向滚动条置底 window.scrollTo(0,document.body.scrollHeight)

四、设置代理ip

ceflib.pas单元:

uses iniFiles;

  procedure TInternalApp.OnBeforeCommandLineProcessing(const processType: ustring;       const commandLine: ICefCommandLine);   var     ini : TIniFile;     str_ip : string;   begin     ini := TIniFile.Create(StringReplace(ParamStr(0),'.exe','.ini',[]);     str_ip := ini.ReadString('default','ProxyIP','')     ini.Free;     commandLine.AppendSwitchWithValue(str_ip);     if Assigned(CefOnBeforeCommandLineProcessing) then       CefOnBeforeCommandLineProcessing(processType, commandLine);   end;

转载于:https://www.cnblogs.com/stroll/p/9942719.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值