Recently wrote your own gadget, need to simulate click on the page picture.
Test page:
Delphi Test Code:
unit unit1;interfaceuses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics,mshtml, vcl.controls, vcl.forms, vcl.dialogs, vcl.olectrls, shdocvw, vcl.appevnts, vcl.stdctrls;type Tform1 = class (Tform) WebBrowser1: TWebBrowser; applicationevents1: tapplicationevents; button1: tbutton; memo1: tmemo; procedure formcreate (Sender: tobject); procedure applicationevents1message (var msg: tagmsg; var handled: Boolean); procedure button1click (Sender: tobject); private { Private declarations } public { public declarations } end;var form1: tform1;implementation{$R *.dfm}procedure Tform1.applicationevents1message (Var msg: tagmsg;var handled: boolean); / /delphi WebBrowser the right-click method is forbidden Begin with msg do begin if not ischild (Webbrowser1.handle, hwnd) then exit; handled := (Message= wm_rbuttondown) or (message= wm_rbuttonup) or (message= Wm_contextmenu); end;end;procedure tform1.button1click (Sender: tobject);var doc: ihtmldocument2; aaa: ihtmlelement; i: integer; s: string;begin doc := webbrowser1.document as ihtmldocument2; if doc.images.length = 0 then exit; memo1.clear; for i := 0 to doc.images.length-1 d o with (Doc.images.item (i,null) as ihtmlimgelement) do begin s := name; s := s + '; ' + href; s := s + '; ' + src; s := s + '; ' + mimeType; s := s + '; ' + dynsrc; s := s + '; ' + vrml; memo1.lines.add (s); Aaa:=doc.images.item (i,null) as IHTMLElement ; aaa.click; end;end;procedure tform1.formcreate (Sender: tobject);begin WebBrowser1.Silent :=true; WebBrowser1.Navigate (Extractfilepath (application.exename) + ' test.html '); end;end.
Operating effect:
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/06/1F/wKiom1myB0PwyogeAAYwGY4U19A312.gif-wh_500x0-wm_ 3-wmp_4-s_312217642.gif "title=" Test.gif "alt=" Wkiom1myb0pwyogeaaywgy4u19a312.gif-wh_50 "/>
This article from "So, OK" blog, please be sure to keep this source http://hji116.blog.51cto.com/3417806/1963618
Delphi analog No ID no Name picture click event