-
Notifications
You must be signed in to change notification settings - Fork 6
/
FF.au3
4398 lines (3997 loc) · 170 KB
/
FF.au3
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include-once
#Region Copyright
#cs
* FF.au3
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ce
#EndRegion Copyright
#Region Many thanks to:
#cs
- Jonathan Bennett and the AutoIt Team for AutoIt v3 the freeware
BASIC-like scripting language
(and thanks John George Kemeny and Thomas Eugene Kurtz for BASIC)
- Dale Hohm, for his great IE.au3, which I've used as base for the
functions-names and the error handling.
- Johannes Schirmer, for some functions and suggestions for the FF.au3
- all others for their suggestions, bug reports ...
- the FireFox-Team for his fantastic browser
- and Massimiliano Mirra, without his work would this UDF impossible,
for MozLab / MozRepl
#ce
#EndRegion Many thanks to:
#Region #CURRENT# ==============================================================
;_FFAction
;_FFClick
;_FFCmd
;_FFConnect
;_FFDialogWait
;_FFDisConnect
;_FFDispatchEvent
;_FFFormCheckBox
;_FFFormGetElementsLength
;_FFFormOptionSelect
;_FFFormRadioButton
;_FFFormReset
;_FFFormSubmit
;_FFFrameEnter
;_FFFrameLeave
;_FFGetLength
;_FFGetObjectInfo
;_FFGetPosition
;_FFGetValue
;_FFImageClick
;_FFImageGetBySize
;_FFImageMapClick
;_FFIsConnected
;_FFLinkClick
;_FFLinksGetAll
;_FFLoadWait
;_FFLoadWaitTimeOut
;_FFObj
;_FFObjDelete
;_FFObjGet
;_FFObjNew
;_FFOpenURL
;_FFPrefGet
;_FFPrefReset
;_FFPrefSet
;_FFQuit
;_FFReadHTML
;_FFReadText
;_FFSearch
;_FFSetValue
;_FFStart
;_FFTabAdd
;_FFTabClose
;_FFTabDuplicate
;_FFTabExists
;_FFTabGetSelected
;_FFTabSetSelected
;_FFTableWriteToArray
;_FFWindowClose
;_FFWindowGetHandle
;_FFWindowOpen
;_FFWindowSelect
;_FFWriteHTML
;_FFXPath
#EndRegion #CURRENT# ==============================================================
#Region Description
; ==============================================================================
; UDF ...........: FF.au3
Global Const $_FF_AU3VERSION = "0.6.0.1b-15"
; Description ...: An UDF for FireFox automation.
; Requirement ...: MozRepl AddOn:
; http://hyperstruct.net/projects/mozlab
; http://wiki.github.com/bard/mozrepl/home
; Author(s) .....: Thorsten Willert, Johannes Schirmer
; Date ..........: Mon Apr 21 15:24:02 CEST 2014 @600 /Internet-Zeit/
; FireFox Version: Firefox/28
; AutoIt Version : v3.3.6.1
; ==============================================================================
#cs
V0.6.0.1b-15 (by Danp2)
- Fixed: Restored declaration of return variable in _FFCmd
- Fixed: SelectWin check of individual tabs by Title
V0.6.0.1b-14 (by Danp2)
- Changed: _FFWindowOpen to allow private browsing
- Changed: _FFWindowGetHandle to improve functionality
- Fixed: _FFTableWriteToArray
- Fixed: __FFStartProcess
- Fixed: __FFWaitForRepl
V0.6.0.1b-13
- Fixed: Changed: CLASS:MozillaUIWindowClass to CLASS:MozillaWindowClass
V0.6.0.1b-12
- Fixed: error in __FFIsIp
V0.6.0.1b-10
- Added: __FFIsIP: IPV6 Support (IVP6, HexCompressed, 6Hex4Dec, Hex4DecCompressed)
V0.6.0.1b-9
- Added: __FFStartProcess: 64bit support
- Added: __FFIsURL: support for intranet
- Changed: _FFQuit now closes FireFox with multiple windows
- Fixed: Connection-limit to MozRepl
V0.6.0.1b-8 (by Danp2)
- Changed: _FFTabExists to allow search by href
- Changed: _FFTabSetSelected to allow selection by href
- Changed: SelectWin to check individual tabs
- Added: FFau3.SearchTabURL helper function
- Fixed: __FFStartProcess
- Fixed: _FFGetPosition
V0.6.0.1b-7
- New: Internal function: __FFMultiDispatchEvent: Dispatches multiple events on one element
- Added: _FFDisPatchEvent can now simulate MouseEvents: click, mousedown, mouseup, mouseover, mousemove, mouseout
- Added: Global constants $_FF_Event_*
- Changed: Removed connection-limit to MozRepl
- Optimized: __FFFilterString
- Optimized: __FFB2S (Bool to string)
- Optimized: __FFIsIP
V0.6.0.1b-6
- Added: Internal function __FFSetTopDocument()
- Changed: Default values for _FFXpath: _FFXPath($sQuery, $sAttribute = "", $iReturnType = 9, $iFilter = 0)
- Changed/Fixed: _FFSearch($sSearchString[, $bCaseSensitive = False[, $bWholeWord = False[, $bSearchInFrames = True]]])
!!! Now you can use as $sSearchString RegExp, too!
- Fixed:
_FFAction
_FFClick
_FFFormSubmit
_FFLoadWait
_FFDisPatchEvent
_FFOpenURL
_FFTabAdd
_FFTabClose
_FFTabSetSelected
now updating the FFau3.WCD-object (window.content.document)
- Fixed: Different problems after _FFTabAdd
- Fixed: Different problems after _FFOpenURL
- Fixed: Error in _FFAu3Option()
<V0.6.x.x
For compatibily for older scripts, please use this UDF:
http://thorsten-willert.de/Themen/FFau3/FF.au3/FFEx.au3
ToDo:
Textsuche (name, id, text ...) per Substring, String, RegEx
Events fuer die _FFForm* Funktionen
Update der Window-Funktionen
#ce
#EndRegion Description
#Region Global Constants
Global Const $_FF_PROC_NAME = "firefox.exe" ; Firefox process name
Global Const $_FF_COM_DELAY_MAX = 200 ; alternative connection delay in ms
Global Enum $_FF_ERROR_Success = 0, _ ; No error
$_FF_ERROR_GeneralError, _ ; General error
$_FF_ERROR_SocketError, _ ; No socket
$_FF_ERROR_InvalidDataType, _ ; Invalid data type (IP, URL, Port ...)
$_FF_ERROR_InvalidValue, _ ; Invalid value in function-call
$_FF_ERROR_SendRecv, _ ; Send / Recv Error
$_FF_ERROR_Timeout, _ ; Connection / Send / Recv timeout
$_FF_ERROR___UNUSED, _ ;
$_FF_ERROR_NoMatch, _ ; No match for _FFAction-find/search _FFGetElement...
$_FF_ERROR_RetValue, _ ; Error echo from Repl e.g. _FFAction("fullscreen","true") <> "true"
$_FF_ERROR_ReplException, _ ; Exception from MozRepl / FireFox
$_FF_ERROR_InvalidExpression ; Invalid expression in XPath query or RegEx
Global Enum Step * 2 $_FF_Event_Change = 1, _
$_FF_Event_Select, _
$_FF_Event_Focus, _
$_FF_Event_Blur, _
$_FF_Event_Resize, _
$_FF_Event_Reset, _
$_FF_Event_Keydown, _
$_FF_Event_Keypress, _
$_FF_Event_Keyup, _
$_FF_Event_Click, _
$_FF_Event_MouseDown, _
$_FF_Event_MouseUp, _
$_FF_Event_MouseOver, _
$_FF_Event_MouseMove, _
$_FF_Event_MouseOut
#EndRegion Global Constants
#Region Global Variables
Global $_FF_GLOBAL_SOCKET = -1 ; Socket
Global $_FF_CON_DELAY ; Connection Delay
Global $_FF_LOADWAIT_TIMEOUT = 120000
Global $_FF_LOADWAIT_STOP = True ; stop loading after $_FF_LOADWAIT_TIMEOUT
Global $_FF_COM_TRACE = True ; Trace communication to console (debugging)
Global $_FF_ERROR_MSGBOX = True ; Shows in compiled scripts error messages in msgboxes
Global $_FF_FRAME = 'top'
Global $_FF_SEARCH_MODE = 0 ; 0 = Substring / 1 = Compare / (2 = RegEx not activ)
#EndRegion Global Variables
; #FUNCTION# ===================================================================
; Name ..........: _FFAction
; Description ...: Some standard actions to work with FireFox
; Beschreibung ..: Standardaktionen in FireFox
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFAction($sAction[, $vOption = ""[, $vOption2 = ""[, $bLoadWait = True]]])
; Parameter(s): .: $sAction - one of the following actions:
; | about
; | alert
; | back
; | blank
; | copy
; | fullscreen / fs
; | hideall
; | home
; | maximize / max
; | minimize / min
; | presentationmode / pm
; | print
; | reload
; | resetconsole
; | restore
; | scrollXY
; | stop
; | zoom
; $vOption - Optional: (Default = "") :
; $vOption2 - Optional: (Default = "") :
; $bLoadWait - Optional: (Default = true) :
; Return Value ..: Success - Return-value from MozRepl (sometimes an empty string!!!)
; Failure - ""
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Sat Feb 26 18:21:40 CET 2011 @765 /Internet Time/
; Link ..........: http://developer.mozilla.org/en/docs/XUL:tabbrowser, http://developer.mozilla.org/en/docs/XUL:Method:reloadWithFlags, https://developer.mozilla.org/En/DOM/Window.scrollBy, http://kb.mozillazine.org/About_Protocol_Links
; Related .......:
; Example .......: Yes
; ==============================================================================
Func _FFAction($sAction, $vOption = "", $vOption2 = "", $bLoadWait = True)
Local Const $sFuncName = "_FFAction"
Local $sCommand
Local $sActionL = StringLower($sAction)
Select
Case $sActionL = "back"
$sCommand = "gBrowser.goBack()"
Case $sActionL = "home"
$sCommand = "gBrowser.goHome()"
Case $sActionL = "forward"
$sCommand = "gBrowser.goForward()"
Case $sActionL = "copy"
Return _FFCmd(".getSelection()", $_FF_CON_DELAY + 100)
Case $sActionL = "reload" And $vOption <> ""
$sCommand = "gBrowser.reloadWithFlags('" & $vOption & "')"
Case $sActionL = "reload"
$sCommand = "gBrowser.reload()"
Case $sActionL = "fullscreen" Or $sActionL = "fs" And $vOption
$sCommand = "fullScreen=true"
$bLoadWait = False
Case $sActionL = "fullscreen" Or $sActionL = "fs" And Not $vOption
$sCommand = "fullScreen=false"
$bLoadWait = False
Case $sActionL = "minimize" Or $sActionL = "min"
$bLoadWait = False
$sCommand = "minimize()"
Case $sActionL = "maximize" Or $sActionL = "max"
$bLoadWait = False
$sCommand = "maximize()"
Case $sActionL = "restore"
$bLoadWait = False
$sCommand = "restore()"
Case $sActionL = "stop"
$bLoadWait = False
$sCommand = "gBrowser.stop()"
Case $sActionL = "print"
$bLoadWait = False
$sCommand = "content.print()"
Case $sActionL = "find" Or $sActionL = "search"
_FFLoadWait()
$sCommand = "content.find()"
Case $sActionL = "hideall" And $vOption
Return _FFCmd("toggleAffectedChrome(true);")
Case $sActionL = "hideall" And Not $vOption
Return _FFCmd("toggleAffectedChrome(false);")
Case $sActionL = "presentationmode" Or $sActionL = "pm" And $vOption
Return _FFCmd("toggleAffectedChrome(true)" & @CRLF & "fullScreen=true")
Case $sActionL = "presentationmode" Or $sActionL = "pm" And Not $vOption
Return _FFCmd("toggleAffectedChrome(false)" & @CRLF & "fullScreen=false")
Case $sActionL = "alert" And $vOption <> ""
$sCommand = 'alert("' & __FFValue2JavaScript($vOption) & '")'
$bLoadWait = False
Case $sActionL = "chrome" And $vOption <> ""
$sCommand = '.location.href="' & __FFChromeSelect($vOption) & '"'
Case $sActionL = "blank"
$vOption = "blank"
ContinueCase
Case $sActionL = "about"
$sCommand = '.location.href="about:' & $vOption & '"'
Case $sActionL = "scrollxy" And IsInt($vOption) And IsInt($vOption2)
$sCommand = "window.content.scrollBy(" & $vOption & "," & $vOption2 & ");"
$bLoadWait = False
Case $sActionL = "zoom" And $vOption = ""
$vOption = 1
ContinueCase
Case $sActionL = "zoom" And IsNumber($vOption)
$sCommand = "gBrowser.selectedBrowser.markupDocumentViewer.fullZoom=" & $vOption
$bLoadWait = False
Case $sActionL = "resetconsole"
$sCommand = ";" & @CRLF & "repl.home()"
$bLoadWait = False
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "$sAction: " & $sAction & " or " & "$vOption :" & $vOption & " or " & "$vOption2 :" & $vOption2))
Return ""
EndSelect
Local $sRet = _FFCmd($sCommand)
If Not @error Then
If $bLoadWait Then _FFLoadWait()
__FFSetTopDocument()
Return $sRet
Else
SetError(@error)
Return ""
EndIf
EndFunc ;==>_FFAction
; #FUNCTION# ===================================================================
; Name ..........: _FFClick
; Description ...: Simulates a click on an element.
; Beschreibung ..: Simuliert einen Klick auf ein Element.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFClick($sElement[, $sMode = "elements"[, $iIndex = 0[, $bLoadWait = True]]])
; Parameter(s): .: $sElement - Element to click on
; $sMode - Optional: (Default = "elements") :
; | elements
; | id
; | name
; | class
; | tag
; $iIndex - Optional: (Default = 0) : Index if $sMode = class, name, tag
; $bLoadWait - Optional: (Default = True) :
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Sat Feb 26 16:57:09 CET 2011 @706 /Internet Time/
; Link ..........:
; Related .......: _FFImageClick, _FFLinkClick. _FFImageMapClick
; Example .......: Yes
; ==============================================================================
Func _FFClick($sElement, $sMode = "elements", $iIndex = 0, $bLoadWait = True)
Local Const $sFuncName = "_FFClick"
If Not IsInt($iIndex) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $iIndex: " & $iIndex))
Return 0
EndIf
If $sMode = Default Then $sMode = "elements"
If $iIndex = Default Then $iIndex = 0
Switch StringLower($sMode)
Case "elements"
If StringLeft($sElement, 7) = "OBJECT|" Then $sElement = StringMid($sElement, 8)
Case "id"
$sElement = ".getElementById('" & $sElement & "')"
Case "name"
$sElement = ".getElementsByName('" & $sElement & "')[" & $iIndex & "]"
Case "class"
$sElement = ".getElementsByClassName('" & $sElement & "')[" & $iIndex & "]"
Case "tag"
$sElement = ".getElementsByTagName('" & $sElement & "')[" & $iIndex & "]"
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(elements|id|name|class|tag) $sMode: " & $sMode))
Return 0
EndSwitch
If StringLeft($sElement, 1) = "." Then $sElement = "FFau3.WCD" & $sElement
Local $RetVal = _FFCmd("FFau3.simulateEvent(" & $sElement & ",'MouseEvents','click');")
If Not @error And $RetVal <> "_FFCmd_Err" And $RetVal = 1 Then
Sleep(25)
If $bLoadWait Then Return _FFLoadWait()
__FFSetTopDocument()
Return 1
Else
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch, "$sElement: " & $sElement))
Return 0
EndIf
EndFunc ;==>_FFClick
; #FUNCTION# ===================================================================
; Name ..........: _FFDialogWait
; Description ...: Waits for a browser-dialog-message (e.g. alert) and closes it.
; Beschreibung ..: Wartet auf ein Dialog-Fenster (z.B.: alert) und schließt es.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFDialogWait($sText[, $sTitle = ""[, $sClose = "close"[, $iTimeOut = 10000]]])
; Parameter(s): .: $sText - Text in the dialog (substring)
; $sTitle - Optional: (Default = "") : Window-title of the dialog (substring)
; $bClose - Optional: (Default = "close") :
; | close = Just closes the dialog window
; | open = Do nothing
; | ok = Uses the "ok"-button
; | cancel = Uses the"cancel"-button
; $iTimeOut - Optional: (Default = 10000) : Timeout for waiting (min. 1000ms)
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Tue Apr 14 12:18:08 CEST 2009
; Link ..........:
; Related .......: _FFLoadWait
; Example .......: Yes
; ==============================================================================
Func _FFDialogWait($sText, $sTitle = "", $sClose = "close", $iTimeOut = 10000)
Local Const $sFuncName = "_FFDialogWait"
If $sTitle = "" And $sText = "" Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "Empty String: $sText and $sTitle"))
Return 0
EndIf
If $sClose = Default Then $sClose = "close"
If $iTimeOut < 1000 Then $iTimeOut = 1000
Local $bFound = False, $b1 = False, $b2 = False
Local $iTimer = TimerInit()
While TimerDiff($iTimer) < $iTimeOut
If _FFCmd('FFau3.obj=Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("").window;' & _
'FFau3.obj.document.documentURI') = "chrome://global/content/commonDialog.xul" Then
If $sTitle <> "" Then
If StringInStr(_FFCmd("FFau3.obj.title"), $sTitle) Then $b1 = True
EndIf
If $sText <> "" Then
If StringInStr(_FFCmd("FFau3.obj.document.documentElement.textContent"), $sText) Then $b2 = True
EndIf
Select
Case $sTitle = "" And $sText <> "" And Not $b1 And $b2
$bFound = True
Case $sTitle <> "" And $sText <> "" And $b1 And $b2
$bFound = True
Case $sTitle <> "" And $sText = "" And $b1 And Not $b2
$bFound = True
Case Else
$bFound = False
EndSelect
If $bFound Then
Switch StringLower($sClose)
Case "close" ; just close the window
_FFCmd("FFau3.obj.close()")
Case "ok"
_FFCmd("FFau3.obj.document.documentElement.acceptDialog()")
Case "cancel"
_FFCmd("FFau3.obj.document.documentElement.cancelDialog()")
Case "open" ; do nothing
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "$sClose: " & $sClose))
Return 0
EndSwitch
Return 1
EndIf
EndIf
Sleep(500)
WEnd
SetError(__FFError($sFuncName, $_FF_ERROR_Timeout, Round(TimerDiff($iTimer)) & "ms > " & $iTimeOut & "ms"))
Return 0
EndFunc ;==>_FFDialogWait
; #FUNCTION# ===================================================================
; Name ..........: _FFImageClick
; Description ...: Clicks an image-link.
; Beschreibung ..: Klickt einen Image-Link.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFImageClick($vSearch[, $sMode = "src"[, $bLoadWait = True]])
; Parameter(s): .: $vSearch - String to search or number (0-n) in index mode (the search is performed in the attributes of the image and the link)
; $sMode - Optional: (Default = "src") :
; | alt
; | href
; | id
; | index
; | name
; | src
; | title
; $bLoadWait - Optional: (Default = True) :
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Fri Dec 04 14:55:57 CET 2009
; Link ..........:
; Related .......: _FFClick, _FFLinkClick, _FFImageMapClick
; Example .......: Yes
; ==============================================================================
Func _FFImageClick($vSearch, $sMode = "src", $bLoadWait = True)
Local Const $sFuncName = "_FFImageClick"
Local $sX
$sMode = StringLower($sMode)
$vSearch = __FFValue2JavaScript($vSearch)
Switch $sMode
Case "index"
If Not IsInt($vSearch) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $vSearch: " & $vSearch))
Return 0
EndIf
$sX = ".images[" & $vSearch & "]"
Case "id", "src", "href", "alt", "name", "title"
Switch $_FF_SEARCH_MODE
Case 0
$sX = "contains(@" & $sMode & ",'" & $vSearch & "')"
Case 1
$sX = "@" & $sMode & "='" & $vSearch & "'"
EndSwitch
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(src|href|alt|name|title|id|index) $sMode: " & $sMode))
Return 0
EndSwitch
If $sMode <> "index" Then
If _FFClick(_FFXPath("//a//img[" & $sX & "] | //a[" & $sX & "]//img", "", 9)) Then
If $bLoadWait Then Return _FFLoadWait()
Return 1
EndIf
Else
If _FFClick($sX) Then
If $bLoadWait Then Return _FFLoadWait()
Return 1
EndIf
EndIf
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch, "$vSearch: " & $vSearch))
Return 0
EndFunc ;==>_FFImageClick
; #FUNCTION# ===================================================================
; Name ..........: _FFImageMapClick
; Description ...: Clicks on area of an image-map
; Beschreibung ..: Klickt auf ein Area einer Image-map
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFImageMapClick($vArea[, $sModeArea = "index"[, $vMap = 0[, $sModeMap = "index"[, $bLoadWait = True]]]])
; Parameter(s): .: $vArea - (substring)
; $sModeArea - Optional: (Default = "index") :
; | alt
; | class
; | coords
; | href
; | id
; | index
; | name
; | title
; $vMap - Optional: (Default = 0) : (substring)
; $sModeMap - Optional: (Default = "index") :
; | class
; | id
; | index
; | name
; | title
; $bLoadWait - Optional: (Default = True) :
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Mon Sep 28 10:39:55 CEST 2009
; Related .......: _FFClick, _FFLinkClick, _FFImageClick
; Example .......: Yes
; ==============================================================================
Func _FFImageMapClick($vArea, $sModeArea = "index", $vMap = 0, $sModeMap = "index", $bLoadWait = True)
Local Const $sFuncName = "_FFImageMapClick"
Local $sXPath
$sModeArea = StringLower($sModeArea)
$sModeMap = StringLower($sModeMap)
Switch $sModeMap
Case "index"
If Not IsInt($vMap) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $vMap: " & $vMap))
Return 0
EndIf
$sXPath = "//map[" & $vMap + 1 & "]"
Case "id", "name", "title", "class"
$sXPath = "//map[contains(@" & $sModeMap & ",'" & $vMap & "')]"
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(name|title|id|index|class) $sModeMap: " & $sModeMap))
Return 0
EndSwitch
Switch $sModeArea
Case "index"
If Not IsInt($vMap) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $vArea: " & $vArea))
Return 0
EndIf
$sXPath &= "//area[" & $vArea & "]"
Case "id", "name", "title", "alt", "href", "class", "coords"
$sXPath &= "//area[contains(@" & $sModeArea & ",'" & $vArea & "')]"
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(index|id|name|title|alt|href|coords|class) $sModeArea: " & $sModeArea))
Return 0
EndSwitch
If _FFClick(_FFXPath($sXPath, "", 9)) Then
If $bLoadWait Then Return _FFLoadWait()
Return 1
EndIf
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch))
Return 0
EndFunc ;==>_FFImageMapClick
; #FUNCTION# ===================================================================
; Name ..........: _FFImagesGetBySize
; Description ...: Returns an array with the index of matching images.
; Beschreibung ..: Liefert ein Array mit den Indizes der passenden Bilder.
; Syntax ........: _FFImagesGetBySize($iHeight, $iWidth[, $sMode = "eq"[, $iPercent = 0]])
; Parameter(s): .: $iHeight - Heigth of the image(s)
; $iWidth - Width of the image(s)
; $sMode - Optional (Default = "eq") :
; | eq
; | lt
; | gt
; $iPercent - Optional (Default = 0) : +/- tolerance in percent for $sMode = "eq" (min=0, max=100)
; Return Value ..: Success - array[0] > 0
; Failure - array[0] = 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Mon Sep 28 10:40:47 CEST 2009
; Link ..........:
; Related .......:
; Example .......: Yes
; ==============================================================================
Func _FFImagesGetBySize($iHeight, $iWidth, $sMode = "eq", $iPercent = 0)
Local Const $sFuncName = "_FFImagesGetBySize"
Local $aRet[1] = [0]
If $iPercent < 0 Or $iPercent > 100 Then $iPercent = 0
$sMode = StringLower($sMode)
If Not IsInt($iHeight) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $iHeight: " & $iHeight))
Return $aRet
EndIf
If Not IsInt($iWidth) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $iWidth: " & $iWidth))
Return $aRet
EndIf
Switch $sMode
Case "eq", "lt", "gt"
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(eq|lt|gt) $sMode: " & $sMode))
Return $aRet
EndSwitch
Local $sCommand = StringFormat("FFau3.SearchImageBySize(%s,%s,'%s',%s);", $iHeight, $iWidth, $sMode, $iPercent)
Local $iIndex = StringStripWS(_FFCmd($sCommand, 10000), 3)
$aRet = StringSplit($iIndex, " ")
If Not @error And $aRet[0] > 0 Then
For $i = 1 To $aRet[0]
$aRet[$i] = Int($aRet[$i])
Next
Else
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch))
Return $aRet
EndIf
Return $aRet
EndFunc ;==>_FFImagesGetBySize
; #FUNCTION# ===================================================================
; Name ..........: _FFLinkClick
; Description ...: Simulates a click on a link.
; Beschreibung ..: Simuliert einen Klick auf einen Link
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFLinkClick($vSearch[, $sMode = "href"[, $bLoadWait = True]])
; Parameter(s): .: $vSearch - (Sub)String to search or number (0-n) in index mode
; $sMode - Optional: (Default = "href") :
; | href
; | alt
; | name
; | title
; | id
; | index
; $bLoadWait - Optional: (Default = True) :
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Fri Jan 22 16:09:48 CET 2010
; Link ..........:
; Related .......: _FFClick, _FFImageClick, _FFImageMapClick
; Example .......: Yes
; ==============================================================================
Func _FFLinkClick($vSearch, $sMode = "href", $bLoadWait = True)
Local Const $sFuncName = "_FFLinkClick"
Local $sX
$sMode = StringLower($sMode)
If Not $sMode = "index" Then $vSearch = __FFValue2JavaScript($vSearch)
Switch $sMode
Case "index"
If Not IsInt($vSearch) Then
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $vSearch: " & $vSearch))
Return 0
EndIf
$sX = ".links[" & $vSearch & "]"
Case "text"
$sX = "//a[contains(.,'" & $vSearch & "')]"
Case "href", "name", "title", "id"
Switch $_FF_SEARCH_MODE
Case 0
$sX = "//a[contains(@" & $sMode & ",'" & $vSearch & "')]"
Case 1
$sX = "//a[@" & $sMode & "='" & $vSearch & "']"
EndSwitch
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(index|href|text|name|title|id) $sMode: " & $sMode))
Return 0
EndSwitch
If $sMode <> "index" Then
Return _FFClick(_FFXPath($sX, "", 9), "elements", 0, $bLoadWait)
Else
Return _FFClick($sX, "elements", 0, $bLoadWait)
EndIf
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch, "$vSearch: " & $vSearch))
Return 0
EndFunc ;==>_FFLinkClick
; #FUNCTION# ===================================================================
; Name ..........: _FFFrameLeave
; Description ...: Leaves the currently entered frame
; Beschreibung ..: Verläßt den aktuellen Frame
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFFrameLeave()
; Parameter(s): .:
; Return Value ..: Success - 1
; Failure - 0
; Author(s) .....: Thorsten Willert
; Date ..........: Fri Sep 18 11:08:20 CEST 2009 @422 /Internet Time/
; Link ..........:
; Related .......: _FFFrameEnter
; Example .......: Yes
; ==============================================================================
Func _FFFrameLeave()
;Local Const $sFuncName = "_FFFrameLeave"
Local $bTrc = $_FF_COM_TRACE
$_FF_COM_TRACE = False
Local $sFrame = StringMid($_FF_FRAME, 1, StringInStr($_FF_FRAME, ".", 2, -1) - 1)
_FFCmd("FFau3.WCD=window.content.wrappedJSObject." & $sFrame & ".document;")
If Not @error Then
$_FF_COM_TRACE = $bTrc
$_FF_FRAME = $sFrame
Return 1
EndIf
$_FF_COM_TRACE = $bTrc
Return 0
EndFunc ;==>_FFFrameLeave
; #FUNCTION# ===================================================================
; Name ..........: _FFFrameEnter
; Description ...: Selects a frame, which all subsequent commands apply on.
; Beschreibung ..: Wählt einen Frame aus, auf den alle nachfolgenden Befehle wirken.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFFrameEnter($vFrame[, $sMode = "index"])
; Parameter(s): .: $vFrame - Frame name or id or number in index mode
; $sMode - Optional: (Default = "index") :
; | name
; | id
; | index
; Return Value ..: Success - 1
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Sat Oct 24 21:05:36 CEST 2009
; Link ..........:
; Related .......: _FFFrameLeave
; Example .......: Yes
; ==============================================================================
Func _FFFrameEnter($vFrame, $sMode = "index")
Local Const $sFuncName = "_FFFrameEnter"
Local $sFrame = $_FF_FRAME
Local $bTrc = $_FF_COM_TRACE
Switch StringLower($sMode)
Case "index"
If IsInt($vFrame) Then
$sFrame &= ".frames[" & $vFrame & "]"
Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(int) $vFrame: " & $vFrame))
Return 0
EndIf
Case "name", "id"
If IsString($vFrame) Then
$sFrame &= "." & $vFrame
Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidDataType, "(string) $vFrame: " & $vFrame))
Return 0
EndIf
Case Else
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "(index|name|id) $sMode: " & $sMode))
Return 0
EndSwitch
$_FF_COM_TRACE = False
_FFCmd("FFau3.WCD=window.content.wrappedJSObject." & $sFrame & ".document;")
If Not @error Then
$_FF_FRAME = $sFrame
$_FF_COM_TRACE = $bTrc
Return 1
EndIf
$_FF_COM_TRACE = $bTrc
SetError(__FFError($sFuncName, $_FF_ERROR_InvalidValue, "Frame not found $vFrame: " & $vFrame))
Return 0
EndFunc ;==>_FFFrameEnter
; #FUNCTION# ===================================================================
; Name ..........: _FFGetLength
; Description ...: Returns the length of the elements in $sMode
; Beschreibung ..: Gibt die Anzahl der angegebenen Elemente zurück.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFGetLength([$sMode = "links"])
; Parameter(s): .: $sMode - Optional: (Default = "links") :
; | links
; | images
; | forms
; | frames
; | anchors
; | tables
; | styleSheets
; | tabs
; | history
; | applets
; | embeds
; | plugins
; | tag
; Return Value ..: Success - Length of the elements
; Failure - 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Mon Mar 23 23:24:13 CET 2009 @975 /Internet Time/
; Link ..........:
; Related .......:
; Example .......: Yes
; ==============================================================================
Func _FFGetLength($sMode = "links")
Local Const $sFuncName = "_FFGetLength"
$sMode = StringLower($sMode)
Switch $sMode
Case "links", "images", "forms", "anchors", "applets", "embeds"
Return _FFCmd("." & $sMode & ".length")
Case "tabs"
Return _FFCmd("gBrowser.tabContainer.childNodes.length")
Case "frames"
Return _FFCmd("content.frames.length")
Case "tables"
Return _FFCmd(".getElementsByTagName('table').length")
Case "history"
Return _FFCmd("content.history.length")
Case "stylesheets"
Return _FFCmd(".styleSheets.length")
Case "plugins"
Return _FFCmd("navigator.plugins.length")
Case Else
Local $RetVal = _FFCmd(".getElementsByTagName('" & $sMode & "').length;")
If Not @error And $RetVal <> "_FFCmd_Err" Then
Return $RetVal
Else
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch, "$sMode: " & $sMode))
Return 0
EndIf
EndSwitch
Return 0
EndFunc ;==>_FFGetLength
; #FUNCTION# ===================================================================
; Name ..........: _FFLinksGetAll
; Description ...: Returns an array with informations about all existing links.
; Beschreibung ..: Gibt ein Array mit Informationen über alle vorhandenen Links zurück.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFLinksGetAll()
; Parameter(s): .:
; Return Value ..: Success - 2 dim array with the link informations:
; | array[n][0] = href
; | array[n][1] = hash
; | array[n][2] = search
; | array[n][3] = name
; | array[n][4] = id
; | array[n][5] = text
; | array[n][6] = innerHTML
; | array[n][7] = target
; | array[n][8] = protocol
; | array[n][9] = port
; Failure - array[0][0] = 0
; @ERROR -
; Author(s) .....: Thorsten Willert
; Date ..........: Tue Sep 22 12:00:34 CEST 2009 @458 /Internet Time/
; Link ..........:
; Related .......:
; Example .......: Yes
; ==============================================================================
Func _FFLinksGetAll()
Local Const $sFuncName = "_FFLinksGetAll"
Local $aInfo, $sInfo, $aRet[1][9], $aTmp
Local $sDelimiter
Local $bTrc = $_FF_COM_TRACE
$_FF_COM_TRACE = False
If _FFGetLength() > 0 Then
$sDelimiter = "FF" & Random(1000, 9999, 1)
$sInfo = _FFCmd('FFau3.GetLinks("' & $sDelimiter & '");')
$aInfo = StringSplit($sInfo, @CRLF)
If @error Then
$_FF_COM_TRACE = $bTrc
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch))
Return $aRet[0][0] = 0
EndIf
ReDim $aRet[$aInfo[0] - 1][9]
For $i = 1 To $aInfo[0] - 1
$aTmp = StringSplit($aInfo[$i], $sDelimiter, 1)
If @error Then
SetError(__FFError($sFuncName, $_FF_ERROR_RetValue, "StringSplit: " & $aInfo[$i]))
ExitLoop
EndIf
If UBound($aTmp) <> 11 Then
$sDelimiter = "FF" & Random(1000, 9999, 1)
$sInfo = _FFCmd("FFau3.GetLinkInfo(" & $i & " ,'top','" & $sDelimiter & "')")
$aTmp = StringSplit($sInfo, $sDelimiter, 1)
EndIf
For $j = 1 To $aTmp[0] - 1
$aRet[$i - 1][$j - 1] = $aTmp[$j]
Next
Next
$_FF_COM_TRACE = $bTrc
Return $aRet
Else
SetError(__FFError($sFuncName, $_FF_ERROR_NoMatch))
$aRet[0][0] = 0
EndIf
$_FF_COM_TRACE = $bTrc
SetError(__FFError($sFuncName, $_FF_ERROR_GeneralError))
Return $aRet[0][0] = 0
EndFunc ;==>_FFLinksGetAll
; #FUNCTION# ===================================================================
; Name ..........: _FFConnect
; Description ...: Connects to FireFox / MozRepl
; Beschreibung ..: Stellt eine Verbindung mit Firefox / MozRepl her.
; AutoIt Version : V3.3.0.0
; Syntax ........: _FFConnect([$IP = "127.0.0.1"[, $iPort = 4242[, $iTimeOut = 60000]]])
; Parameter(s): .: $IP - Optional: (Default = "127.0.0.1") :
; $iPort - Optional: (Default = 4242) :
; $iTimeOut - Optional: (Default = 60000) :
; Return Value ..: Success - 1 / $_FF_GLOBAL_SOCKET > -1
; @EXTENDED - 1 = Non Browser-window
; | 2 = Browser-window