如何使用程序自动移动鼠标单击或双击浏览器内的非特定联接?(200分)

  • 主题发起人 主题发起人 hawkliu
  • 开始时间 开始时间
H

hawkliu

Unregistered / Unconfirmed
GUEST, unregistred user!
如何使用程序自动移动鼠标单击或双击浏览器内的联接<br>最好有个例子看看
 
procedure TForm1.Button1Click(Sender: TObject);<br>var Point:TPoint;<br>begin<br>&nbsp; GetCursorPos(Point);<br>&nbsp; Mouse_Event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);<br>&nbsp; Mouse_Event(MOUSEEVENTF_LEFTUP,0,0,0,0);<br>&nbsp; SetCursorPos(Point.X + 100, Point.Y + 10);//改为浏览器内的按扭的X,Y<br>&nbsp; Mouse_Event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);<br>&nbsp; Mouse_Event(MOUSEEVENTF_LEFTUP,0,0,0,0);<br>end;
 
==&gt;来自:joioy<br><br>如果鼠标当时指向的是一个文本框(此文本框没有句柄),要向此文本框发送一字符串文字,字符串中的文字为变量S中的值,如: S:='abcdefg'; 要用键盘消息发送(keybd_event),该如何写?
 
这个不知道对你有没有帮助:<br>自动点击连接<br>unit Unit1; <br><br>interface <br><br>uses <br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, <br>&nbsp; OleCtrls, SHDocVw, StdCtrls, ExtCtrls,MSHtml; <br><br>type <br>&nbsp; TForm1 = class(TForm) <br>&nbsp; &nbsp; Panel1: TPanel; <br>&nbsp; &nbsp; Edit1: TEdit; <br>&nbsp; &nbsp; Label1: TLabel; <br>&nbsp; &nbsp; NavigateBtn: TButton; <br>&nbsp; &nbsp; WebBrowser1: TWebBrowser; <br>&nbsp; &nbsp; procedure NavigateBtnClick(Sender: TObject); <br>&nbsp; &nbsp; procedure WebBrowser1DocumentComplete(Sender: TObject; <br>&nbsp; &nbsp; &nbsp; const pDisp: IDispatch; var URL: OleVariant); <br>&nbsp; private <br>&nbsp; &nbsp; { Private declarations } <br>&nbsp; public <br>&nbsp; &nbsp; { Public declarations } <br>&nbsp; end; <br><br>var <br>&nbsp; Form1: TForm1; <br><br>implementation <br><br>{$R *.DFM} <br><br>procedure TForm1.NavigateBtnClick(Sender: TObject); <br>begin <br>&nbsp; webbrowser1.Navigate(edit1.text); <br><br>end; <br><br>procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; <br>&nbsp; const pDisp: IDispatch; var URL: OleVariant); <br>var <br>&nbsp; Links:IHTMLElementCollection; <br>&nbsp; Doc:IHTMLDocument2; <br>&nbsp; len:integer; <br>&nbsp; item:olevariant; <br>begin <br>&nbsp; Doc:=webbrowser1.document as IHtmlDocument2; <br>&nbsp; links:=Doc.links; <br>&nbsp; len:=links.length; <br>&nbsp; if len&gt;0 &nbsp;then <br>&nbsp; begin <br>&nbsp; &nbsp; Item:=links.item(0,varEmpty); <br>&nbsp; &nbsp; item.click; <br>&nbsp; end; <br>end; <br><br>end. <br>
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
832
SUNSTONE的Delphi笔记
S
S
回复
0
查看
791
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部