-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuCefScriptClickElement.pas
100 lines (86 loc) · 2.82 KB
/
uCefScriptClickElement.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
unit uCefScriptClickElement;
interface
uses
//
//
uCefScriptBase, uCefScriptNavBase, uCefWebAction, uCefUtilType;
type
TScriptClickElement = class(TCefScriptNavBase)
private
FSpeed: Integer;
FTag: string;
FId: string;
FName: string;
FClass: string;
FAttrName: string;
FValueRegExpr: string;
FTextRegExpr: string;
protected
function DoNavEvent(const AWebAction: TCefWebAction): Boolean; override;
public
constructor Create(const ASpeed: TCefUISpeed; const ATag, AId, AName,
AClass, AAttrName, AAttrValueRegExpr, ATextRegExpr: string;
const ASetAsNav: Boolean;
const AParent: TCefScriptBase); overload;
constructor Create(const ASpeed: TCefUISpeed; const AId: string;
const ASetAsNav: Boolean;
const AParent: TCefScriptBase); overload;
constructor Create(const AId: string; const ASetAsNav: Boolean;
const AParent: TCefScriptBase); overload;
class function GetScriptName: string; override;
end;
implementation
uses
//
uCefUIFunc, uCefUtilConst;
{ TScriptClickElement }
constructor TScriptClickElement.Create(const ASpeed: TCefUISpeed; const ATag, AId, AName,
AClass, AAttrName, AAttrValueRegExpr, ATextRegExpr: string; const ASetAsNav: Boolean;
const AParent: TCefScriptBase);
begin
inherited Create('', ASetAsNav, AParent);
FSpeed := ASpeed;
FTag := ATag;
FId := AId;
FName := AName;
FClass := AClass;
FAttrName := AAttrName;
FValueRegExpr := AAttrValueRegExpr;
FTextRegExpr := ATextRegExpr;
//
if FSpeed = 0 then
FSpeed := SPEED_DEF
end;
constructor TScriptClickElement.Create(const ASpeed: TCefUISpeed; const AId: string;
const ASetAsNav: Boolean; const AParent: TCefScriptBase);
begin
Create(ASpeed, '', AId, '', '', '', '', '', ASetAsNav, AParent)
end;
constructor TScriptClickElement.Create(const AId: string;
const ASetAsNav: Boolean; const AParent: TCefScriptBase);
begin
Create(AParent.Controller.Speed, AId, ASetAsNav, AParent)
end;
function TScriptClickElement.DoNavEvent(const AWebAction: TCefWebAction): Boolean;
var bol: Boolean;
begin
bol := CefUIScrollToElement(Chromium.Browser, FAbortEvent, FSpeed, FTag, FId, FName, FClass, FAttrName, FValueRegExpr, FTextRegExpr);
if not bol then
begin
FailMsg2('fail scroll to element');
Exit(False);
end;
bol := CefUIMouseMoveToElement(Chromium.Browser, FAbortEvent, FController.Cursor, FSpeed, False, FTag, FId, FName, FClass, FAttrName, FValueRegExpr, FTextRegExpr);
if not bol then
begin
FailMsg2('fail mouse move to element');
Exit(False);
end;
CefUIMouseClick(Self);// Chromium.Browser, FController.Cursor);
Exit(True);
end;
class function TScriptClickElement.GetScriptName: string;
begin
Result := 'click';
end;
end.