IE_En.au3 146 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440
  1. #include-once
  2. #include "AutoItConstants.au3"
  3. #include "FileConstants.au3"
  4. #include "WinAPIError.au3"
  5. ; #INDEX# =======================================================================================================================
  6. ; Title .........: Internet Explorer Automation UDF Library for AutoIt3
  7. ; AutoIt Version : 3.3.14.5
  8. ; Language ......: English
  9. ; Description ...: A collection of functions for creating, attaching to, reading from and manipulating Internet Explorer.
  10. ; Author(s) .....: DaleHohm, big_daddy, jpm
  11. ; Dll ...........: user32.dll, ole32.dll, oleacc.dll
  12. ; ===============================================================================================================================
  13. #Region Header
  14. #cs
  15. Title: Internet Explorer Automation UDF Library for AutoIt3
  16. Filename: IE.au3
  17. Description: A collection of functions for creating, attaching to, reading from and manipulating Internet Explorer
  18. Author: DaleHohm
  19. Modified: jpm, Jon
  20. Version: T3.0-2
  21. Last Update: 14/08/19
  22. Requirements: AutoIt3 3.3.9 or higher
  23. Update History:
  24. ===================================================
  25. T3.0-2 14/8/19
  26. Enhancements
  27. - Updated __IEErrorHandlerRegister to work with or without COM errors being fatal
  28. T3.0-1 13/6/2
  29. Enhancements
  30. - Fixed _IE_Introduction, _IE_Examples generate HTML5
  31. - Added check in __IEComErrorUnrecoverable for COM error -2147023174, "RPC server not accessible."
  32. - Fixed check in __IEComErrorUnrecoverable for COM error -2147024891, "Access is denied."
  33. - Fixed check in __IEComErrorUnrecoverable for COM error -2147352567, "an exception has occurred."
  34. - Fixed __IEIsObjType() not restoring _IEErrorNotify()
  35. - Fixed $b_mustUnlock on Error in _IECreate()
  36. - Fixed no timeout cheking if error in _IELoadWait()
  37. - Fixed HTML5 support in _IEImgClick(), _IEFormImageClick()
  38. - Fixed _IEHeadInsertEventScript() COM error return
  39. - Updated _IEErrorNotify() default keyword support
  40. - Updated rename __IENotify() to __IEConsoleWriteError() and restore calling @error
  41. - Removed __IEInternalErrorHandler() (not used any more)
  42. - Updated Function Headers
  43. - Updated doc and splitting and checking examples
  44. T3.0-0 12/9/3
  45. Fixes
  46. - Removed _IEErrorHandlerRegister() and all internal calls to it. Unneeded as COM errors are no longer fatal
  47. - Removed code deprecated in V2
  48. - Fixed _IELoadWait check for unrecoverable COM errors
  49. - Removed Vcard support from _IEPropertyGet (IE removed support in IE7)
  50. - Code cleanup with #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6
  51. New Features
  52. - Added "scrollIntoView" to _IEAction
  53. Enhancements
  54. - Added check in __IEComErrorUnrecoverable for COM error -2147023179, "The interface is unknown."
  55. - Added "Trap COM error, report and return" to functions that perform blind method calls (those without return values)
  56. ===================================================
  57. #ce
  58. #EndRegion Header
  59. ; #VARIABLES# ===================================================================================================================
  60. #Region Global Variables
  61. Global $__g_iIELoadWaitTimeout = 300000 ; 5 Minutes
  62. Global $__g_bIEAU3Debug = False
  63. Global $__g_bIEErrorNotify = True
  64. Global $__g_oIEErrorHandler, $__g_sIEUserErrorHandler
  65. #EndRegion Global Variables
  66. ; ===============================================================================================================================
  67. ; #CONSTANTS# ===================================================================================================================
  68. #Region Global Constants
  69. Global Const $__gaIEAU3VersionInfo[6] = ["T", 3, 0, 2, "20140819", "T3.0-2"]
  70. Global Const $LSFW_LOCK = 1, $LSFW_UNLOCK = 2
  71. ;
  72. ; Enums
  73. ;
  74. Global Enum _; Error Status Types
  75. $_IESTATUS_Success = 0, _
  76. $_IESTATUS_GeneralError, _
  77. $_IESTATUS_ComError, _
  78. $_IESTATUS_InvalidDataType, _
  79. $_IESTATUS_InvalidObjectType, _
  80. $_IESTATUS_InvalidValue, _
  81. $_IESTATUS_LoadWaitTimeout, _
  82. $_IESTATUS_NoMatch, _
  83. $_IESTATUS_AccessIsDenied, _
  84. $_IESTATUS_ClientDisconnected
  85. ;~ Global Enum Step * 2 _; NotificationLevel
  86. ;~ $_IENotifyLevel_None = 0, _
  87. ;~ $_IENotifyNotifyLevel_Warning = 1, _
  88. ;~ $_IENotifyNotifyLevel_Error, _
  89. ;~ $_IENotifyNotifyLevel_ComError
  90. ;~ Global Enum Step * 2 _; NotificationMethod
  91. ;~ $_IENotifyMethod_Silent = 0, _
  92. ;~ $_IENotifyMethod_Console = 1, _
  93. ;~ $_IENotifyMethod_ToolTip, _
  94. ;~ $_IENotifyMethod_MsgBox
  95. #EndRegion Global Constants
  96. ; ===============================================================================================================================
  97. ; #NO_DOC_FUNCTION# =============================================================================================================
  98. ; _IEErrorHandlerRegister
  99. ; _IEErrorHandlerDeRegister
  100. ; ===============================================================================================================================
  101. ; #CURRENT# =====================================================================================================================
  102. ; _IECreate
  103. ; _IECreateEmbedded
  104. ; _IENavigate
  105. ; _IEAttach
  106. ; _IELoadWait
  107. ; _IELoadWaitTimeout
  108. ;
  109. ; _IEIsFrameSet
  110. ; _IEFrameGetCollection
  111. ; _IEFrameGetObjByName
  112. ;
  113. ; _IELinkClickByText
  114. ; _IELinkClickByIndex
  115. ; _IELinkGetCollection
  116. ;
  117. ; _IEImgClick
  118. ; _IEImgGetCollection
  119. ;
  120. ; _IEFormGetCollection
  121. ; _IEFormGetObjByName
  122. ; _IEFormElementGetCollection
  123. ; _IEFormElementGetObjByName
  124. ; _IEFormElementGetValue
  125. ; _IEFormElementSetValue
  126. ; _IEFormElementOptionSelect
  127. ; _IEFormElementCheckBoxSelect
  128. ; _IEFormElementRadioSelect
  129. ; _IEFormImageClick
  130. ; _IEFormSubmit
  131. ; _IEFormReset
  132. ;
  133. ; _IETableGetCollection
  134. ; _IETableWriteToArray
  135. ;
  136. ; _IEBodyReadHTML
  137. ; _IEBodyReadText
  138. ; _IEBodyWriteHTML
  139. ; _IEDocReadHTML
  140. ; _IEDocWriteHTML
  141. ; _IEDocInsertText
  142. ; _IEDocInsertHTML
  143. ; _IEHeadInsertEventScript
  144. ;
  145. ; _IEDocGetObj
  146. ; _IETagNameGetCollection
  147. ; _IETagNameAllGetCollection
  148. ; _IEGetObjByName
  149. ; _IEGetObjById
  150. ; _IEAction
  151. ; _IEPropertyGet
  152. ; _IEPropertySet
  153. ; _IEErrorNotify
  154. ; _IEQuit
  155. ;
  156. ; _IE_Introduction
  157. ; _IE_Example
  158. ; _IE_VersionInfo
  159. ; ===============================================================================================================================
  160. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  161. ; __IELockSetForegroundWindow
  162. ; __IEControlGetObjFromHWND
  163. ; __IERegisterWindowMessage
  164. ; __IESendMessageTimeout
  165. ; __IEIsObjType
  166. ; __IEConsoleWriteError
  167. ; __IEComErrorUnrecoverable
  168. ;
  169. ; __IEInternalErrorHandler
  170. ; __IEInternalErrorHandlerRegister
  171. ; __IENavigate
  172. ; __IECreateNewIE
  173. ; __IETempFile
  174. ;
  175. ; __IEStringToBstr
  176. ; __IEBstrToString
  177. ; ===============================================================================================================================
  178. #Region Core functions
  179. ; #FUNCTION# ====================================================================================================================
  180. ; Author ........: Dale Hohm
  181. ; Modified ......: jpm
  182. ; ===============================================================================================================================
  183. Func _IECreate($sUrl = "about:blank", $iTryAttach = 0, $iVisible = 1, $iWait = 1, $iTakeFocus = 1)
  184. If Not $iVisible Then $iTakeFocus = 0 ; Force takeFocus to 0 for hidden window
  185. If $iTryAttach Then
  186. Local $oResult = _IEAttach($sUrl, "url")
  187. If IsObj($oResult) Then
  188. If $iTakeFocus Then WinActivate(HWnd($oResult.hWnd))
  189. Return SetError($_IESTATUS_Success, 1, $oResult)
  190. EndIf
  191. EndIf
  192. Local $iMustUnlock = 0
  193. If Not $iVisible And __IELockSetForegroundWindow($LSFW_LOCK) Then $iMustUnlock = 1
  194. Local $oObject = ObjCreate("InternetExplorer.Application")
  195. If Not IsObj($oObject) Then
  196. __IEConsoleWriteError("Error", "_IECreate", "", "Browser Object Creation Failed")
  197. If $iMustUnlock Then __IELockSetForegroundWindow($LSFW_UNLOCK)
  198. Return SetError($_IESTATUS_GeneralError, 0, 0)
  199. EndIf
  200. $oObject.visible = $iVisible
  201. ; If the unlock doesn't work we may have created an unwanted modal window
  202. If $iMustUnlock And Not __IELockSetForegroundWindow($LSFW_UNLOCK) Then __IEConsoleWriteError("Warning", "_IECreate", "", "Foreground Window Unlock Failed!")
  203. _IENavigate($oObject, $sUrl, $iWait)
  204. ; Store @error after _IENavigate() so that it can be returned.
  205. Local $iError = @error
  206. ; IE9 sets focus to the URL bar when an about: URI is displayed (such as about:blank). This can cause
  207. ; _IEAction(..., "focus") to work incorrectly. It will give focus to the element (as shown by the elements's
  208. ; appearance changing but) the input caret will not move. The work-around for this "helpful" behavior is
  209. ; to explicitly give focus to the document. We should only do this for about: URIs and on successful
  210. ; navigate.
  211. If Not $iError And StringLeft($sUrl, 6) = "about:" Then
  212. Local $oDocument = $oObject.document
  213. _IEAction($oDocument, "focus")
  214. EndIf
  215. Return SetError($iError, 0, $oObject)
  216. EndFunc ;==>_IECreate
  217. ; #FUNCTION# ====================================================================================================================
  218. ; Author ........: Dale Hohm
  219. ; ===============================================================================================================================
  220. Func _IECreateEmbedded()
  221. Local $oObject = ObjCreate("Shell.Explorer.2")
  222. If Not IsObj($oObject) Then
  223. __IEConsoleWriteError("Error", "_IECreateEmbedded", "", "WebBrowser Object Creation Failed")
  224. Return SetError($_IESTATUS_GeneralError, 0, 0)
  225. EndIf
  226. ;
  227. Return SetError($_IESTATUS_Success, 0, $oObject)
  228. EndFunc ;==>_IECreateEmbedded
  229. ; #FUNCTION# ====================================================================================================================
  230. ; Author ........: Dale Hohm
  231. ; ===============================================================================================================================
  232. Func _IENavigate(ByRef $oObject, $sUrl, $iWait = 1)
  233. If Not IsObj($oObject) Then
  234. __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidDataType")
  235. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  236. EndIf
  237. ;
  238. If Not __IEIsObjType($oObject, "documentContainer") Then
  239. __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_InvalidObjectType")
  240. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  241. EndIf
  242. ;
  243. $oObject.navigate($sUrl)
  244. If @error Then ; Trap COM error, report and return
  245. __IEConsoleWriteError("Error", "_IENavigate", "$_IESTATUS_COMError", @error)
  246. Return SetError($_IESTATUS_ComError, @error, 0)
  247. EndIf
  248. If $iWait Then
  249. _IELoadWait($oObject)
  250. Return SetError(@error, 0, -1)
  251. EndIf
  252. Return SetError($_IESTATUS_Success, 0, -1)
  253. EndFunc ;==>_IENavigate
  254. ; #FUNCTION# ====================================================================================================================
  255. ; Author ........: Dale Hohm
  256. ; ===============================================================================================================================
  257. Func _IEAttach($sString, $sMode = "title", $iInstance = 1)
  258. $sMode = StringLower($sMode)
  259. $iInstance = Int($iInstance)
  260. If $iInstance < 1 Then
  261. __IEConsoleWriteError("Error", "_IEAttach", "$_IESTATUS_InvalidValue", "$iInstance < 1")
  262. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  263. EndIf
  264. If $sMode = "embedded" Or $sMode = "dialogbox" Then
  265. Local $iWinTitleMatchMode = Opt("WinTitleMatchMode", $OPT_MATCHANY)
  266. If $sMode = "dialogbox" And $iInstance > 1 Then
  267. If IsHWnd($sString) Then
  268. $iInstance = 1
  269. __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_GeneralError", "$iInstance > 1 invalid with HWnd and DialogBox. Setting to 1.")
  270. Else
  271. Local $aWinlist = WinList($sString, "")
  272. If $iInstance <= $aWinlist[0][0] Then
  273. $sString = $aWinlist[$iInstance][1]
  274. $iInstance = 1
  275. Else
  276. __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch")
  277. Opt("WinTitleMatchMode", $iWinTitleMatchMode)
  278. Return SetError($_IESTATUS_NoMatch, 1, 0)
  279. EndIf
  280. EndIf
  281. EndIf
  282. Local $hControl = ControlGetHandle($sString, "", "[CLASS:Internet Explorer_Server; INSTANCE:" & $iInstance & "]")
  283. Local $oResult = __IEControlGetObjFromHWND($hControl)
  284. Opt("WinTitleMatchMode", $iWinTitleMatchMode)
  285. If IsObj($oResult) Then
  286. Return SetError($_IESTATUS_Success, 0, $oResult)
  287. Else
  288. __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch")
  289. Return SetError($_IESTATUS_NoMatch, 1, 0)
  290. EndIf
  291. EndIf
  292. Local $oShell = ObjCreate("Shell.Application")
  293. Local $oShellWindows = $oShell.Windows(); collection of all ShellWindows (IE and File Explorer)
  294. Local $iTmp = 1
  295. Local $iNotifyStatus, $bIsBrowser, $sTmp
  296. Local $bStatus
  297. For $oWindow In $oShellWindows
  298. ;------------------------------------------------------------------------------------------
  299. ; Check to verify that the window object is a valid browser, if not, skip it
  300. ;
  301. ; Setup internal error handler to Trap COM errors, turn off error notification,
  302. ; check object property validity, set a flag and reset error handler and notification
  303. ;
  304. $bIsBrowser = True
  305. ; Trap COM errors and turn off error notification
  306. $bStatus = __IEInternalErrorHandlerRegister()
  307. If Not $bStatus Then __IEConsoleWriteError("Warning", "_IEAttach", _
  308. "Cannot register internal error handler, cannot trap COM errors", _
  309. "Use _IEErrorHandlerRegister() to register a user error handler")
  310. ; Turn off error notification for internal processing
  311. $iNotifyStatus = _IEErrorNotify() ; save current error notify status
  312. _IEErrorNotify(False)
  313. ; Check conditions to verify that the object is a browser
  314. If $bIsBrowser Then
  315. $sTmp = $oWindow.type ; Is .type a valid property?
  316. If @error Then $bIsBrowser = False
  317. EndIf
  318. If $bIsBrowser Then
  319. $sTmp = $oWindow.document.title ; Does object have a .document and .title property?
  320. If @error Then $bIsBrowser = False
  321. EndIf
  322. ; restore error notify
  323. _IEErrorNotify($iNotifyStatus) ; restore notification status
  324. __IEInternalErrorHandlerDeRegister()
  325. ;------------------------------------------------------------------------------------------
  326. If $bIsBrowser Then
  327. Switch $sMode
  328. Case "title"
  329. If StringInStr($oWindow.document.title, $sString) > 0 Then
  330. If $iInstance = $iTmp Then
  331. Return SetError($_IESTATUS_Success, 0, $oWindow)
  332. Else
  333. $iTmp += 1
  334. EndIf
  335. EndIf
  336. Case "instance"
  337. If $iInstance = $iTmp Then
  338. Return SetError($_IESTATUS_Success, 0, $oWindow)
  339. Else
  340. $iTmp += 1
  341. EndIf
  342. Case "windowtitle"
  343. Local $bFound = False
  344. $sTmp = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\", "Window Title")
  345. If Not @error Then
  346. If StringInStr($oWindow.document.title & " - " & $sTmp, $sString) Then $bFound = True
  347. Else
  348. If StringInStr($oWindow.document.title & " - Microsoft Internet Explorer", $sString) Then $bFound = True
  349. If StringInStr($oWindow.document.title & " - Windows Internet Explorer", $sString) Then $bFound = True
  350. EndIf
  351. If $bFound Then
  352. If $iInstance = $iTmp Then
  353. Return SetError($_IESTATUS_Success, 0, $oWindow)
  354. Else
  355. $iTmp += 1
  356. EndIf
  357. EndIf
  358. Case "url"
  359. If StringInStr($oWindow.LocationURL, $sString) > 0 Then
  360. If $iInstance = $iTmp Then
  361. Return SetError($_IESTATUS_Success, 0, $oWindow)
  362. Else
  363. $iTmp += 1
  364. EndIf
  365. EndIf
  366. Case "text"
  367. If StringInStr($oWindow.document.body.innerText, $sString) > 0 Then
  368. If $iInstance = $iTmp Then
  369. Return SetError($_IESTATUS_Success, 0, $oWindow)
  370. Else
  371. $iTmp += 1
  372. EndIf
  373. EndIf
  374. Case "html"
  375. If StringInStr($oWindow.document.body.innerHTML, $sString) > 0 Then
  376. If $iInstance = $iTmp Then
  377. Return SetError($_IESTATUS_Success, 0, $oWindow)
  378. Else
  379. $iTmp += 1
  380. EndIf
  381. EndIf
  382. Case "hwnd"
  383. If $iInstance > 1 Then
  384. $iInstance = 1
  385. __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_GeneralError", "$iInstance > 1 invalid with HWnd. Setting to 1.")
  386. EndIf
  387. If _IEPropertyGet($oWindow, "hwnd") = $sString Then
  388. Return SetError($_IESTATUS_Success, 0, $oWindow)
  389. EndIf
  390. Case Else
  391. ; Invalid Mode
  392. __IEConsoleWriteError("Error", "_IEAttach", "$_IESTATUS_InvalidValue", "Invalid Mode Specified")
  393. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  394. EndSwitch
  395. EndIf
  396. Next
  397. __IEConsoleWriteError("Warning", "_IEAttach", "$_IESTATUS_NoMatch")
  398. Return SetError($_IESTATUS_NoMatch, 1, 0)
  399. EndFunc ;==>_IEAttach
  400. ; #FUNCTION# ====================================================================================================================
  401. ; Author ........: Dale Hohm
  402. ; Modified ......: jpm
  403. ; ===============================================================================================================================
  404. Func _IELoadWait(ByRef $oObject, $iDelay = 0, $iTimeout = -1)
  405. If Not IsObj($oObject) Then
  406. __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_InvalidDataType")
  407. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  408. EndIf
  409. If Not __IEIsObjType($oObject, "browserdom") Then
  410. __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_InvalidObjectType", ObjName($oObject))
  411. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  412. EndIf
  413. Local $oTemp, $bAbort = False, $iErrorStatusCode = $_IESTATUS_Success
  414. ; Setup internal error handler to Trap COM errors, turn off error notification
  415. Local $bStatus = __IEInternalErrorHandlerRegister()
  416. If Not $bStatus Then __IEConsoleWriteError("Warning", "_IELoadWait", _
  417. "Cannot register internal error handler, cannot trap COM errors", _
  418. "Use _IEErrorHandlerRegister() to register a user error handler")
  419. Local $iNotifyStatus = _IEErrorNotify() ; save current error notify status
  420. _IEErrorNotify(False)
  421. Sleep($iDelay)
  422. ;
  423. Local $iError
  424. Local $hIELoadWaitTimer = TimerInit()
  425. If $iTimeout = -1 Then $iTimeout = $__g_iIELoadWaitTimeout
  426. Select
  427. Case __IEIsObjType($oObject, "browser", False); Internet Explorer
  428. While Not (String($oObject.readyState) = "complete" Or $oObject.readyState = 4 Or $bAbort)
  429. ; Trap unrecoverable COM errors
  430. If @error Then
  431. $iError = @error
  432. If __IEComErrorUnrecoverable($iError) Then
  433. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  434. $bAbort = True
  435. EndIf
  436. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  437. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  438. $bAbort = True
  439. EndIf
  440. Sleep(100)
  441. WEnd
  442. While Not (String($oObject.document.readyState) = "complete" Or $oObject.document.readyState = 4 Or $bAbort)
  443. ; Trap unrecoverable COM errors
  444. If @error Then
  445. $iError = @error
  446. If __IEComErrorUnrecoverable($iError) Then
  447. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  448. $bAbort = True
  449. EndIf
  450. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  451. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  452. $bAbort = True
  453. EndIf
  454. Sleep(100)
  455. WEnd
  456. Case __IEIsObjType($oObject, "window", False) ; Window, Frame, iFrame
  457. While Not (String($oObject.document.readyState) = "complete" Or $oObject.document.readyState = 4 Or $bAbort)
  458. ; Trap unrecoverable COM errors
  459. If @error Then
  460. $iError = @error
  461. If __IEComErrorUnrecoverable($iError) Then
  462. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  463. $bAbort = True
  464. EndIf
  465. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  466. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  467. $bAbort = True
  468. EndIf
  469. Sleep(100)
  470. WEnd
  471. While Not (String($oObject.top.document.readyState) = "complete" Or $oObject.top.document.readyState = 4 Or $bAbort)
  472. ; Trap unrecoverable COM errors
  473. If @error Then
  474. $iError = @error
  475. If __IEComErrorUnrecoverable($iError) Then
  476. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  477. $bAbort = True
  478. EndIf
  479. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  480. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  481. $bAbort = True
  482. EndIf
  483. Sleep(100)
  484. WEnd
  485. Case __IEIsObjType($oObject, "document", False) ; Document
  486. $oTemp = $oObject.parentWindow
  487. While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort)
  488. ; Trap unrecoverable COM errors
  489. If @error Then
  490. $iError = @error
  491. If __IEComErrorUnrecoverable($iError) Then
  492. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  493. $bAbort = True
  494. EndIf
  495. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  496. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  497. $bAbort = True
  498. EndIf
  499. Sleep(100)
  500. WEnd
  501. While Not (String($oTemp.top.document.readyState) = "complete" Or $oTemp.top.document.readyState = 4 Or $bAbort)
  502. ; Trap unrecoverable COM errors
  503. If @error Then
  504. $iError = @error
  505. If __IEComErrorUnrecoverable($iError) Then
  506. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  507. $bAbort = True
  508. EndIf
  509. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  510. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  511. $bAbort = True
  512. EndIf
  513. Sleep(100)
  514. WEnd
  515. Case Else ; this should work with any other DOM object
  516. $oTemp = $oObject.document.parentWindow
  517. While Not (String($oTemp.document.readyState) = "complete" Or $oTemp.document.readyState = 4 Or $bAbort)
  518. ; Trap unrecoverable COM errors
  519. If @error Then
  520. $iError = @error
  521. If __IEComErrorUnrecoverable($iError) Then
  522. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  523. $bAbort = True
  524. EndIf
  525. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  526. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  527. $bAbort = True
  528. EndIf
  529. Sleep(100)
  530. WEnd
  531. While Not (String($oTemp.top.document.readyState) = "complete" Or $oObject.top.document.readyState = 4 Or $bAbort)
  532. ; Trap unrecoverable COM errors
  533. If @error Then
  534. $iError = @error
  535. If __IEComErrorUnrecoverable($iError) Then
  536. $iErrorStatusCode = __IEComErrorUnrecoverable($iError)
  537. $bAbort = True
  538. EndIf
  539. ElseIf (TimerDiff($hIELoadWaitTimer) > $iTimeout) Then
  540. $iErrorStatusCode = $_IESTATUS_LoadWaitTimeout
  541. $bAbort = True
  542. EndIf
  543. Sleep(100)
  544. WEnd
  545. EndSelect
  546. ; restore error notify
  547. _IEErrorNotify($iNotifyStatus) ; restore notification status
  548. __IEInternalErrorHandlerDeRegister()
  549. Switch $iErrorStatusCode
  550. Case $_IESTATUS_Success
  551. Return SetError($_IESTATUS_Success, 0, 1)
  552. Case $_IESTATUS_LoadWaitTimeout
  553. __IEConsoleWriteError("Warning", "_IELoadWait", "$_IESTATUS_LoadWaitTimeout")
  554. Return SetError($_IESTATUS_LoadWaitTimeout, 3, 0)
  555. Case $_IESTATUS_AccessIsDenied
  556. __IEConsoleWriteError("Warning", "_IELoadWait", "$_IESTATUS_AccessIsDenied", _
  557. "Cannot verify readyState. Likely casue: cross-domain scripting security restriction. (" & $iError & ")")
  558. Return SetError($_IESTATUS_AccessIsDenied, 0, 0)
  559. Case $_IESTATUS_ClientDisconnected
  560. __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_ClientDisconnected", _
  561. $iError & ", Browser has been deleted prior to operation.")
  562. Return SetError($_IESTATUS_ClientDisconnected, 0, 0)
  563. Case Else
  564. __IEConsoleWriteError("Error", "_IELoadWait", "$_IESTATUS_GeneralError", "Invalid Error Status - Notify IE.au3 developer")
  565. Return SetError($_IESTATUS_GeneralError, 0, 0)
  566. EndSwitch
  567. EndFunc ;==>_IELoadWait
  568. ; #FUNCTION# ====================================================================================================================
  569. ; Author ........: Dale Hohm
  570. ; ===============================================================================================================================
  571. Func _IELoadWaitTimeout($iTimeout = -1)
  572. If $iTimeout = -1 Then
  573. Return SetError($_IESTATUS_Success, 0, $__g_iIELoadWaitTimeout)
  574. Else
  575. $__g_iIELoadWaitTimeout = $iTimeout
  576. Return SetError($_IESTATUS_Success, 0, 1)
  577. EndIf
  578. EndFunc ;==>_IELoadWaitTimeout
  579. #EndRegion Core functions
  580. #Region Frame Functions
  581. ; Security Note on Frame functions:
  582. ; Note that security restriction in Internet Explorer related to cross-site scripting
  583. ; between frames can cause serious problems with the frame functions. Functions that
  584. ; work connected to one site will fail when connected to another depending on the sites
  585. ; referenced in the frames. In general, if all the referenced pages are on the same
  586. ; webserver these functions should work as described; if not, unexpected COM failures
  587. ; can occur.
  588. ; #FUNCTION# ====================================================================================================================
  589. ; Author ........: Dale Hohm
  590. ; ===============================================================================================================================
  591. Func _IEIsFrameSet(ByRef $oObject)
  592. ; Note: this is more reliable test for a FrameSet than checking the
  593. ; number of frames (document.frames.length) because iFrames embedded on a normal
  594. ; page are included in the frame collection even though it is not a FrameSet
  595. If Not IsObj($oObject) Then
  596. __IEConsoleWriteError("Error", "_IEIsFrameSet", "$_IESTATUS_InvalidDataType")
  597. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  598. EndIf
  599. ;
  600. If String($oObject.document.body.tagName) = "frameset" Then
  601. Return SetError($_IESTATUS_Success, 0, 1)
  602. Else
  603. If @error Then ; Trap COM error, report and return
  604. __IEConsoleWriteError("Error", "_IEIsFrameSet", "$_IESTATUS_COMError", @error)
  605. Return SetError($_IESTATUS_ComError, @error, 0)
  606. EndIf
  607. Return SetError($_IESTATUS_Success, 0, 0)
  608. EndIf
  609. EndFunc ;==>_IEIsFrameSet
  610. ; #FUNCTION# ====================================================================================================================
  611. ; Author ........: Dale Hohm
  612. ; ===============================================================================================================================
  613. Func _IEFrameGetCollection(ByRef $oObject, $iIndex = -1)
  614. If Not IsObj($oObject) Then
  615. __IEConsoleWriteError("Error", "_IEFrameGetCollection", "$_IESTATUS_InvalidDataType")
  616. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  617. EndIf
  618. ;
  619. $iIndex = Number($iIndex)
  620. Select
  621. Case $iIndex = -1
  622. Return SetError($_IESTATUS_Success, $oObject.document.parentwindow.frames.length, _
  623. $oObject.document.parentwindow.frames)
  624. Case $iIndex > -1 And $iIndex < $oObject.document.parentwindow.frames.length
  625. Return SetError($_IESTATUS_Success, $oObject.document.parentwindow.frames.length, _
  626. $oObject.document.parentwindow.frames.item($iIndex))
  627. Case $iIndex < -1
  628. __IEConsoleWriteError("Error", "_IEFrameGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  629. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  630. Case Else
  631. __IEConsoleWriteError("Warning", "_IEFrameGetCollection", "$_IESTATUS_NoMatch")
  632. Return SetError($_IESTATUS_NoMatch, 2, 0)
  633. EndSelect
  634. EndFunc ;==>_IEFrameGetCollection
  635. ; #FUNCTION# ====================================================================================================================
  636. ; Author ........: Dale Hohm
  637. ; ===============================================================================================================================
  638. Func _IEFrameGetObjByName(ByRef $oObject, $sName)
  639. If Not IsObj($oObject) Then
  640. __IEConsoleWriteError("Error", "_IEFrameGetObjByName", "$_IESTATUS_InvalidDataType")
  641. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  642. EndIf
  643. ;
  644. Local $oTemp, $oFrames
  645. If Not __IEIsObjType($oObject, "browserdom") Then
  646. __IEConsoleWriteError("Error", "_IEFrameGetObjByName", "$_IESTATUS_InvalidObjectType")
  647. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  648. EndIf
  649. If __IEIsObjType($oObject, "document") Then
  650. $oTemp = $oObject.parentWindow
  651. Else
  652. $oTemp = $oObject.document.parentWindow
  653. EndIf
  654. If _IEIsFrameSet($oTemp) Then
  655. $oFrames = _IETagNameGetCollection($oTemp, "frame")
  656. Else
  657. $oFrames = _IETagNameGetCollection($oTemp, "iframe")
  658. EndIf
  659. If $oFrames.length Then
  660. For $oFrame In $oFrames
  661. If String($oFrame.name) = $sName Then Return SetError($_IESTATUS_Success, 0, $oTemp.frames($sName))
  662. Next
  663. __IEConsoleWriteError("Warning", "_IEFrameGetObjByName", "$_IESTATUS_NoMatch", "No frames matching name")
  664. Return SetError($_IESTATUS_NoMatch, 2, 0)
  665. Else
  666. __IEConsoleWriteError("Warning", "_IEFrameGetObjByName", "$_IESTATUS_NoMatch", "No Frames found")
  667. Return SetError($_IESTATUS_NoMatch, 2, 0)
  668. EndIf
  669. EndFunc ;==>_IEFrameGetObjByName
  670. #EndRegion Frame Functions
  671. #Region Link functions
  672. ; #FUNCTION# ====================================================================================================================
  673. ; Author ........: Dale Hohm
  674. ; ===============================================================================================================================
  675. Func _IELinkClickByText(ByRef $oObject, $sLinkText, $iIndex = 0, $iWait = 1)
  676. If Not IsObj($oObject) Then
  677. __IEConsoleWriteError("Error", "_IELinkClickByText", "$_IESTATUS_InvalidDataType")
  678. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  679. EndIf
  680. ;
  681. Local $iFound = 0, $sModeLinktext, $oLinks = $oObject.document.links
  682. $iIndex = Number($iIndex)
  683. For $oLink In $oLinks
  684. $sModeLinktext = String($oLink.outerText)
  685. If $sModeLinktext = $sLinkText Then
  686. If ($iFound = $iIndex) Then
  687. $oLink.click()
  688. If @error Then ; Trap COM error, report and return
  689. __IEConsoleWriteError("Error", "_IELinkClickByText", "$_IESTATUS_COMError", @error)
  690. Return SetError($_IESTATUS_ComError, @error, 0)
  691. EndIf
  692. If $iWait Then
  693. _IELoadWait($oObject)
  694. Return SetError(@error, 0, -1)
  695. EndIf
  696. Return SetError($_IESTATUS_Success, 0, -1)
  697. EndIf
  698. $iFound = $iFound + 1
  699. EndIf
  700. Next
  701. __IEConsoleWriteError("Warning", "_IELinkClickByText", "$_IESTATUS_NoMatch")
  702. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
  703. EndFunc ;==>_IELinkClickByText
  704. ; #FUNCTION# ====================================================================================================================
  705. ; Author ........: Dale Hohm
  706. ; ===============================================================================================================================
  707. Func _IELinkClickByIndex(ByRef $oObject, $iIndex, $iWait = 1)
  708. If Not IsObj($oObject) Then
  709. __IEConsoleWriteError("Error", "_IELinkClickByIndex", "$_IESTATUS_InvalidDataType")
  710. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  711. EndIf
  712. ;
  713. Local $oLinks = $oObject.document.links, $oLink
  714. $iIndex = Number($iIndex)
  715. If ($iIndex >= 0) And ($iIndex <= $oLinks.length - 1) Then
  716. $oLink = $oLinks($iIndex)
  717. $oLink.click()
  718. If @error Then ; Trap COM error, report and return
  719. __IEConsoleWriteError("Error", "_IELinkClickByIndex", "$_IESTATUS_COMError", @error)
  720. Return SetError($_IESTATUS_ComError, @error, 0)
  721. EndIf
  722. If $iWait Then
  723. _IELoadWait($oObject)
  724. Return SetError(@error, 0, -1)
  725. EndIf
  726. Return SetError($_IESTATUS_Success, 0, -1)
  727. Else
  728. __IEConsoleWriteError("Warning", "_IELinkClickByIndex", "$_IESTATUS_NoMatch")
  729. Return SetError($_IESTATUS_NoMatch, 2, 0)
  730. EndIf
  731. EndFunc ;==>_IELinkClickByIndex
  732. ; #FUNCTION# ====================================================================================================================
  733. ; Author ........: Dale Hohm
  734. ; ===============================================================================================================================
  735. Func _IELinkGetCollection(ByRef $oObject, $iIndex = -1)
  736. If Not IsObj($oObject) Then
  737. __IEConsoleWriteError("Error", "_IELinkGetCollection", "$_IESTATUS_InvalidDataType")
  738. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  739. EndIf
  740. ;
  741. $iIndex = Number($iIndex)
  742. Select
  743. Case $iIndex = -1
  744. Return SetError($_IESTATUS_Success, $oObject.document.links.length, _
  745. $oObject.document.links)
  746. Case $iIndex > -1 And $iIndex < $oObject.document.links.length
  747. Return SetError($_IESTATUS_Success, $oObject.document.links.length, _
  748. $oObject.document.links.item($iIndex))
  749. Case $iIndex < -1
  750. __IEConsoleWriteError("Error", "_IELinkGetCollection", "$_IESTATUS_InvalidValue")
  751. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  752. Case Else
  753. __IEConsoleWriteError("Warning", "_IELinkGetCollection", "$_IESTATUS_NoMatch")
  754. Return SetError($_IESTATUS_NoMatch, 2, 0)
  755. EndSelect
  756. EndFunc ;==>_IELinkGetCollection
  757. #EndRegion Link functions
  758. #Region Image functions
  759. ; #FUNCTION# ====================================================================================================================
  760. ; Author ........: Dale Hohm
  761. ; Modified ......: jpm
  762. ; ===============================================================================================================================
  763. Func _IEImgClick(ByRef $oObject, $sLinkText, $sMode = "src", $iIndex = 0, $iWait = 1)
  764. If Not IsObj($oObject) Then
  765. __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_InvalidDataType")
  766. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  767. EndIf
  768. ;
  769. Local $sModeLinktext, $iFound = 0, $oImgs = $oObject.document.images
  770. $sMode = StringLower($sMode)
  771. $iIndex = Number($iIndex)
  772. For $oImg In $oImgs
  773. Select
  774. Case $sMode = "alt"
  775. $sModeLinktext = $oImg.alt
  776. Case $sMode = "name"
  777. $sModeLinktext = $oImg.name
  778. If Not IsString($sModeLinktext) Then $sModeLinktext = $oImg.id ; html5 support
  779. Case $sMode = "id"
  780. $sModeLinktext = $oImg.id
  781. Case $sMode = "src"
  782. $sModeLinktext = $oImg.src
  783. Case Else
  784. __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_InvalidValue", "Invalid mode: " & $sMode)
  785. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  786. EndSelect
  787. If StringInStr($sModeLinktext, $sLinkText) Then
  788. If ($iFound = $iIndex) Then
  789. $oImg.click()
  790. If @error Then ; Trap COM error, report and return
  791. __IEConsoleWriteError("Error", "_IEImgClick", "$_IESTATUS_COMError", @error)
  792. Return SetError($_IESTATUS_ComError, @error, 0)
  793. EndIf
  794. If $iWait Then
  795. _IELoadWait($oObject)
  796. Return SetError(@error, 0, -1)
  797. EndIf
  798. Return SetError($_IESTATUS_Success, 0, -1)
  799. EndIf
  800. $iFound = $iFound + 1
  801. EndIf
  802. Next
  803. __IEConsoleWriteError("Warning", "_IEImgClick", "$_IESTATUS_NoMatch")
  804. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 4 or both
  805. EndFunc ;==>_IEImgClick
  806. ; #FUNCTION# ====================================================================================================================
  807. ; Author ........: Dale Hohm
  808. ; ===============================================================================================================================
  809. Func _IEImgGetCollection(ByRef $oObject, $iIndex = -1)
  810. If Not IsObj($oObject) Then
  811. __IEConsoleWriteError("Error", "_IEImgGetCollection", "$_IESTATUS_InvalidDataType")
  812. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  813. EndIf
  814. ;
  815. Local $oTemp = _IEDocGetObj($oObject)
  816. $iIndex = Number($iIndex)
  817. Select
  818. Case $iIndex = -1
  819. Return SetError($_IESTATUS_Success, $oTemp.images.length, $oTemp.images)
  820. Case $iIndex > -1 And $iIndex < $oTemp.images.length
  821. Return SetError($_IESTATUS_Success, $oTemp.images.length, $oTemp.images.item($iIndex))
  822. Case $iIndex < -1
  823. __IEConsoleWriteError("Error", "_IEImgGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  824. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  825. Case Else
  826. __IEConsoleWriteError("Warning", "_IEImgGetCollection", "$_IESTATUS_NoMatch")
  827. Return SetError($_IESTATUS_NoMatch, 1, 0)
  828. EndSelect
  829. EndFunc ;==>_IEImgGetCollection
  830. #EndRegion Image functions
  831. #Region Form functions
  832. ; #FUNCTION# ====================================================================================================================
  833. ; Author ........: Dale Hohm
  834. ; ===============================================================================================================================
  835. Func _IEFormGetCollection(ByRef $oObject, $iIndex = -1)
  836. If Not IsObj($oObject) Then
  837. __IEConsoleWriteError("Error", "_IEFormGetCollection", "$_IESTATUS_InvalidDataType")
  838. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  839. EndIf
  840. ;
  841. Local $oTemp = _IEDocGetObj($oObject)
  842. $iIndex = Number($iIndex)
  843. Select
  844. Case $iIndex = -1
  845. Return SetError($_IESTATUS_Success, $oTemp.forms.length, $oTemp.forms)
  846. Case $iIndex > -1 And $iIndex < $oTemp.forms.length
  847. Return SetError($_IESTATUS_Success, $oTemp.forms.length, $oTemp.forms.item($iIndex))
  848. Case $iIndex < -1
  849. __IEConsoleWriteError("Error", "_IEFormGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  850. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  851. Case Else
  852. __IEConsoleWriteError("Warning", "_IEFormGetCollection", "$_IESTATUS_NoMatch")
  853. Return SetError($_IESTATUS_NoMatch, 1, 0)
  854. EndSelect
  855. EndFunc ;==>_IEFormGetCollection
  856. ; #FUNCTION# ====================================================================================================================
  857. ; Author ........: Dale Hohm
  858. ; ===============================================================================================================================
  859. Func _IEFormGetObjByName(ByRef $oObject, $sName, $iIndex = 0)
  860. If Not IsObj($oObject) Then
  861. __IEConsoleWriteError("Error", "_IEFormGetObjByName", "$_IESTATUS_InvalidDataType")
  862. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  863. EndIf
  864. ;
  865. ;----- Determine valid collection length
  866. Local $iLength = 0
  867. Local $oCol = $oObject.document.forms.item($sName)
  868. If IsObj($oCol) Then
  869. If __IEIsObjType($oCol, "elementcollection") Then
  870. $iLength = $oCol.length
  871. Else
  872. $iLength = 1
  873. EndIf
  874. EndIf
  875. ;-----
  876. $iIndex = Number($iIndex)
  877. If $iIndex = -1 Then
  878. Return SetError($_IESTATUS_Success, $iLength, $oObject.document.forms.item($sName))
  879. Else
  880. If IsObj($oObject.document.forms.item($sName, $iIndex)) Then
  881. Return SetError($_IESTATUS_Success, $iLength, $oObject.document.forms.item($sName, $iIndex))
  882. Else
  883. __IEConsoleWriteError("Warning", "_IEFormGetObjByName", "$_IESTATUS_NoMatch")
  884. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
  885. EndIf
  886. EndIf
  887. EndFunc ;==>_IEFormGetObjByName
  888. ; #FUNCTION# ====================================================================================================================
  889. ; Author ........: Dale Hohm
  890. ; ===============================================================================================================================
  891. Func _IEFormElementGetCollection(ByRef $oObject, $iIndex = -1)
  892. If Not IsObj($oObject) Then
  893. __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidDataType")
  894. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  895. EndIf
  896. ;
  897. If Not __IEIsObjType($oObject, "form") Then
  898. __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidObjectType")
  899. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  900. EndIf
  901. ;
  902. $iIndex = Number($iIndex)
  903. Select
  904. Case $iIndex = -1
  905. Return SetError($_IESTATUS_Success, $oObject.elements.length, $oObject.elements)
  906. Case $iIndex > -1 And $iIndex < $oObject.elements.length
  907. Return SetError($_IESTATUS_Success, $oObject.elements.length, $oObject.elements.item($iIndex))
  908. Case $iIndex < -1
  909. __IEConsoleWriteError("Error", "_IEFormElementGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  910. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  911. Case Else
  912. Return SetError($_IESTATUS_NoMatch, 1, 0)
  913. EndSelect
  914. EndFunc ;==>_IEFormElementGetCollection
  915. ; #FUNCTION# ====================================================================================================================
  916. ; Author ........: Dale Hohm
  917. ; ===============================================================================================================================
  918. Func _IEFormElementGetObjByName(ByRef $oObject, $sName, $iIndex = 0)
  919. If Not IsObj($oObject) Then
  920. __IEConsoleWriteError("Error", "_IEFormElementGetObjByName", "$_IESTATUS_InvalidDataType")
  921. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  922. EndIf
  923. ;
  924. If Not __IEIsObjType($oObject, "form") Then
  925. __IEConsoleWriteError("Error", "_IEFormElementGetObjByName", "$_IESTATUS_InvalidObjectType")
  926. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  927. EndIf
  928. ;
  929. ;----- Determine valid collection length
  930. Local $iLength = 0
  931. Local $oCol = $oObject.elements.item($sName)
  932. If IsObj($oCol) Then
  933. If __IEIsObjType($oCol, "elementcollection") Then
  934. $iLength = $oCol.length
  935. Else
  936. $iLength = 1
  937. EndIf
  938. EndIf
  939. ;-----
  940. $iIndex = Number($iIndex)
  941. If $iIndex = -1 Then
  942. Return SetError($_IESTATUS_Success, $iLength, $oObject.elements.item($sName))
  943. Else
  944. If IsObj($oObject.elements.item($sName, $iIndex)) Then
  945. Return SetError($_IESTATUS_Success, $iLength, $oObject.elements.item($sName, $iIndex))
  946. Else
  947. __IEConsoleWriteError("Warning", "_IEFormElementGetObjByName", "$_IESTATUS_NoMatch")
  948. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
  949. EndIf
  950. EndIf
  951. EndFunc ;==>_IEFormElementGetObjByName
  952. ; #FUNCTION# ====================================================================================================================
  953. ; Author ........: Dale Hohm
  954. ; ===============================================================================================================================
  955. Func _IEFormElementGetValue(ByRef $oObject)
  956. If Not IsObj($oObject) Then
  957. __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_InvalidDataType")
  958. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  959. EndIf
  960. ;
  961. If Not __IEIsObjType($oObject, "forminputelement") Then
  962. __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_InvalidObjectType")
  963. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  964. EndIf
  965. ;
  966. Local $sReturn = String($oObject.value)
  967. If @error Then ; Trap COM error, report and return
  968. __IEConsoleWriteError("Error", "_IEFormElementGetValue", "$_IESTATUS_COMError", @error)
  969. Return SetError($_IESTATUS_ComError, @error, 0)
  970. EndIf
  971. SetError($_IESTATUS_Success)
  972. Return $sReturn
  973. EndFunc ;==>_IEFormElementGetValue
  974. ; #FUNCTION# ====================================================================================================================
  975. ; Author ........: Dale Hohm
  976. ; ===============================================================================================================================
  977. Func _IEFormElementSetValue(ByRef $oObject, $sNewValue, $iFireEvent = 1)
  978. If Not IsObj($oObject) Then
  979. __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidDataType")
  980. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  981. EndIf
  982. ;
  983. If Not __IEIsObjType($oObject, "forminputelement") Then
  984. __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidObjectType")
  985. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  986. EndIf
  987. ;
  988. If String($oObject.type) = "file" Then
  989. __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_InvalidObjectType", "Browser security prevents SetValue of TYPE=FILE")
  990. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  991. EndIf
  992. ;
  993. $oObject.value = $sNewValue
  994. If @error Then ; Trap COM error, report and return
  995. __IEConsoleWriteError("Error", "_IEFormElementSetValue", "$_IESTATUS_COMError", @error)
  996. Return SetError($_IESTATUS_ComError, @error, 0)
  997. EndIf
  998. If $iFireEvent Then
  999. $oObject.fireEvent("OnChange")
  1000. $oObject.fireEvent("OnClick")
  1001. EndIf
  1002. Return SetError($_IESTATUS_Success, 0, 1)
  1003. EndFunc ;==>_IEFormElementSetValue
  1004. ; #FUNCTION# ====================================================================================================================
  1005. ; Author ........: Dale Hohm
  1006. ; Modified ......: benners
  1007. ; ===============================================================================================================================
  1008. Func _IEFormElementOptionSelect(ByRef $oObject, $sString, $iSelect = 1, $sMode = "byValue", $iFireEvent = 1)
  1009. If Not IsObj($oObject) Then
  1010. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidDataType")
  1011. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1012. EndIf
  1013. ;
  1014. If Not __IEIsObjType($oObject, "formselectelement") Then
  1015. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidObjectType")
  1016. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1017. EndIf
  1018. ;
  1019. Local $oItem, $oItems = $oObject.options, $iNumItems = $oObject.options.length, $bIsMultiple = $oObject.multiple
  1020. Switch $sMode
  1021. Case "byValue"
  1022. For $oItem In $oItems
  1023. If $oItem.value = $sString Then
  1024. Switch $iSelect
  1025. Case -1
  1026. Return SetError($_IESTATUS_Success, 0, $oItem.selected)
  1027. Case 0
  1028. If Not $bIsMultiple Then
  1029. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _
  1030. "$iSelect=0 only valid for type=select multiple")
  1031. Return SetError($_IESTATUS_InvalidValue, 3)
  1032. EndIf
  1033. If $oItem.selected Then
  1034. $oItem.selected = False
  1035. If $iFireEvent Then
  1036. $oObject.fireEvent("onChange")
  1037. $oObject.fireEvent("OnClick")
  1038. EndIf
  1039. EndIf
  1040. Return SetError($_IESTATUS_Success, 0, 1)
  1041. Case 1
  1042. If Not $oItem.selected Then
  1043. $oItem.selected = True
  1044. If $iFireEvent Then
  1045. $oObject.fireEvent("onChange")
  1046. $oObject.fireEvent("OnClick")
  1047. EndIf
  1048. EndIf
  1049. Return SetError($_IESTATUS_Success, 0, 1)
  1050. Case Else
  1051. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value")
  1052. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1053. EndSwitch
  1054. EndIf
  1055. Next
  1056. __IEConsoleWriteError("Warning", "_IEFormElementOptionSelect", "$_IESTATUS_NoMatch", "Value not matched")
  1057. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1058. Case "byText"
  1059. For $oItem In $oItems
  1060. If String($oItem.text) = $sString Then
  1061. Switch $iSelect
  1062. Case -1
  1063. Return SetError($_IESTATUS_Success, 0, $oItem.selected)
  1064. Case 0
  1065. If Not $bIsMultiple Then
  1066. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _
  1067. "$iSelect=0 only valid for type=select multiple")
  1068. Return SetError($_IESTATUS_InvalidValue, 3)
  1069. EndIf
  1070. If $oItem.selected Then
  1071. $oItem.selected = False
  1072. If $iFireEvent Then
  1073. $oObject.fireEvent("onChange")
  1074. $oObject.fireEvent("OnClick")
  1075. EndIf
  1076. EndIf
  1077. Return SetError($_IESTATUS_Success, 0, 1)
  1078. Case 1
  1079. If Not $oItem.selected Then
  1080. $oItem.selected = True
  1081. If $iFireEvent Then
  1082. $oObject.fireEvent("onChange")
  1083. $oObject.fireEvent("OnClick")
  1084. EndIf
  1085. EndIf
  1086. Return SetError($_IESTATUS_Success, 0, 1)
  1087. Case Else
  1088. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value")
  1089. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1090. EndSwitch
  1091. EndIf
  1092. Next
  1093. __IEConsoleWriteError("Warning", "_IEFormElementOptionSelect", "$_IESTATUS_NoMatch", "Text not matched")
  1094. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1095. Case "byIndex"
  1096. Local $iIndex = Number($sString)
  1097. If $iIndex < 0 Or $iIndex >= $iNumItems Then
  1098. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid index value, " & $iIndex)
  1099. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  1100. EndIf
  1101. $oItem = $oItems.item($iIndex)
  1102. Switch $iSelect
  1103. Case -1
  1104. Return SetError($_IESTATUS_Success, 0, $oItems.item($iIndex).selected)
  1105. Case 0
  1106. If Not $bIsMultiple Then
  1107. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", _
  1108. "$iSelect=0 only valid for type=select multiple")
  1109. Return SetError($_IESTATUS_InvalidValue, 3)
  1110. EndIf
  1111. If $oItem.selected Then
  1112. $oItems.item($iIndex).selected = False
  1113. If $iFireEvent Then
  1114. $oObject.fireEvent("onChange")
  1115. $oObject.fireEvent("OnClick")
  1116. EndIf
  1117. EndIf
  1118. Return SetError($_IESTATUS_Success, 0, 1)
  1119. Case 1
  1120. If Not $oItem.selected Then
  1121. $oItems.item($iIndex).selected = True
  1122. If $iFireEvent Then
  1123. $oObject.fireEvent("onChange")
  1124. $oObject.fireEvent("OnClick")
  1125. EndIf
  1126. EndIf
  1127. Return SetError($_IESTATUS_Success, 0, 1)
  1128. Case Else
  1129. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value")
  1130. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1131. EndSwitch
  1132. Case Else
  1133. __IEConsoleWriteError("Error", "_IEFormElementOptionSelect", "$_IESTATUS_InvalidValue", "Invalid Mode")
  1134. Return SetError($_IESTATUS_InvalidValue, 4, 0)
  1135. EndSwitch
  1136. EndFunc ;==>_IEFormElementOptionSelect
  1137. ; #FUNCTION# ====================================================================================================================
  1138. ; Author ........: Dale Hohm
  1139. ; ===============================================================================================================================
  1140. Func _IEFormElementCheckBoxSelect(ByRef $oObject, $sString, $sName = "", $iSelect = 1, $sMode = "byValue", $iFireEvent = 1)
  1141. If Not IsObj($oObject) Then
  1142. __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidDataType")
  1143. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1144. EndIf
  1145. ;
  1146. If Not __IEIsObjType($oObject, "form") Then
  1147. __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidObjectType")
  1148. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1149. EndIf
  1150. ;
  1151. $sString = String($sString)
  1152. $sName = String($sName)
  1153. Local $oItems
  1154. If $sName = "" Then
  1155. $oItems = _IETagNameGetCollection($oObject, "input")
  1156. Else
  1157. $oItems = Execute("$oObject.elements('" & $sName & "')")
  1158. EndIf
  1159. If Not IsObj($oItems) Then
  1160. __IEConsoleWriteError("Warning", "_IEFormElementCheckBoxSelect", "$_IESTATUS_NoMatch")
  1161. Return SetError($_IESTATUS_NoMatch, 3, 0)
  1162. EndIf
  1163. Local $oItem, $bFound = False
  1164. Switch $sMode
  1165. Case "byValue"
  1166. If __IEIsObjType($oItems, "forminputelement") Then
  1167. $oItem = $oItems
  1168. If String($oItem.type) = "checkbox" And String($oItem.value) = $sString Then $bFound = True
  1169. Else
  1170. For $oItem In $oItems
  1171. If String($oItem.type) = "checkbox" And String($oItem.value) = $sString Then
  1172. $bFound = True
  1173. ExitLoop
  1174. EndIf
  1175. Next
  1176. EndIf
  1177. Case "byIndex"
  1178. If __IEIsObjType($oItems, "forminputelement") Then
  1179. $oItem = $oItems
  1180. If String($oItem.type) = "checkbox" And Number($sString) = 0 Then $bFound = True
  1181. Else
  1182. Local $iCount = 0
  1183. For $oItem In $oItems
  1184. If String($oItem.type) = "checkbox" And Number($sString) = $iCount Then
  1185. $bFound = True
  1186. ExitLoop
  1187. Else
  1188. If String($oItem.type) = "checkbox" Then $iCount += 1
  1189. EndIf
  1190. Next
  1191. EndIf
  1192. Case Else
  1193. __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidValue", "Invalid Mode")
  1194. Return SetError($_IESTATUS_InvalidValue, 5, 0)
  1195. EndSwitch
  1196. If Not $bFound Then
  1197. __IEConsoleWriteError("Warning", "_IEFormElementCheckBoxSelect", "$_IESTATUS_NoMatch")
  1198. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1199. EndIf
  1200. Switch $iSelect
  1201. Case -1
  1202. Return SetError($_IESTATUS_Success, 0, $oItem.checked)
  1203. Case 0
  1204. If $oItem.checked Then
  1205. $oItem.checked = False
  1206. If $iFireEvent Then
  1207. $oItem.fireEvent("onChange")
  1208. $oItem.fireEvent("OnClick")
  1209. EndIf
  1210. EndIf
  1211. Return SetError($_IESTATUS_Success, 0, 1)
  1212. Case 1
  1213. If Not $oItem.checked Then
  1214. $oItem.checked = True
  1215. If $iFireEvent Then
  1216. $oItem.fireEvent("onChange")
  1217. $oItem.fireEvent("OnClick")
  1218. EndIf
  1219. EndIf
  1220. Return SetError($_IESTATUS_Success, 0, 1)
  1221. Case Else
  1222. __IEConsoleWriteError("Error", "_IEFormElementCheckBoxSelect", "$_IESTATUS_InvalidValue", "Invalid $iSelect value")
  1223. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1224. EndSwitch
  1225. EndFunc ;==>_IEFormElementCheckBoxSelect
  1226. ; #FUNCTION# ====================================================================================================================
  1227. ; Author ........: Dale Hohm
  1228. ; ===============================================================================================================================
  1229. Func _IEFormElementRadioSelect(ByRef $oObject, $sString, $sName, $iSelect = 1, $sMode = "byValue", $iFireEvent = 1)
  1230. If Not IsObj($oObject) Then
  1231. __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidDataType")
  1232. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1233. EndIf
  1234. ;
  1235. If Not __IEIsObjType($oObject, "form") Then
  1236. __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidObjectType")
  1237. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1238. EndIf
  1239. ;
  1240. $sString = String($sString)
  1241. $sName = String($sName)
  1242. Local $oItems = Execute("$oObject.elements('" & $sName & "')")
  1243. If Not IsObj($oItems) Then
  1244. __IEConsoleWriteError("Warning", "_IEFormElementRadioSelect", "$_IESTATUS_NoMatch")
  1245. Return SetError($_IESTATUS_NoMatch, 3, 0)
  1246. EndIf
  1247. Local $oItem, $bFound = False
  1248. Switch $sMode
  1249. Case "byValue"
  1250. If __IEIsObjType($oItems, "forminputelement") Then
  1251. $oItem = $oItems
  1252. If String($oItem.type) = "radio" And String($oItem.value) = $sString Then $bFound = True
  1253. Else
  1254. For $oItem In $oItems
  1255. If String($oItem.type) = "radio" And String($oItem.value) = $sString Then
  1256. $bFound = True
  1257. ExitLoop
  1258. EndIf
  1259. Next
  1260. EndIf
  1261. Case "byIndex"
  1262. If __IEIsObjType($oItems, "forminputelement") Then
  1263. $oItem = $oItems
  1264. If String($oItem.type) = "radio" And Number($sString) = 0 Then $bFound = True
  1265. Else
  1266. Local $iCount = 0
  1267. For $oItem In $oItems
  1268. If String($oItem.type) = "radio" And Number($sString) = $iCount Then
  1269. $bFound = True
  1270. ExitLoop
  1271. Else
  1272. $iCount += 1
  1273. EndIf
  1274. Next
  1275. EndIf
  1276. Case Else
  1277. __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidValue", "Invalid Mode")
  1278. Return SetError($_IESTATUS_InvalidValue, 5, 0)
  1279. EndSwitch
  1280. If Not $bFound Then
  1281. __IEConsoleWriteError("Warning", "_IEFormElementRadioSelect", "$_IESTATUS_NoMatch")
  1282. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1283. EndIf
  1284. Switch $iSelect
  1285. Case -1
  1286. Return SetError($_IESTATUS_Success, 0, $oItem.checked)
  1287. Case 0
  1288. If $oItem.checked Then
  1289. $oItem.checked = False
  1290. If $iFireEvent Then
  1291. $oItem.fireEvent("onChange")
  1292. $oItem.fireEvent("OnClick")
  1293. EndIf
  1294. EndIf
  1295. Return SetError($_IESTATUS_Success, 0, 1)
  1296. Case 1
  1297. If Not $oItem.checked Then
  1298. $oItem.checked = True
  1299. If $iFireEvent Then
  1300. $oItem.fireEvent("onChange")
  1301. $oItem.fireEvent("OnClick")
  1302. EndIf
  1303. EndIf
  1304. Return SetError($_IESTATUS_Success, 0, 1)
  1305. Case Else
  1306. __IEConsoleWriteError("Error", "_IEFormElementRadioSelect", "$_IESTATUS_InvalidValue", "$iSelect value invalid")
  1307. Return SetError($_IESTATUS_InvalidValue, 4, 0)
  1308. EndSwitch
  1309. EndFunc ;==>_IEFormElementRadioSelect
  1310. ; #FUNCTION# ====================================================================================================================
  1311. ; Author ........: Dale Hohm
  1312. ; Modified ......: jpm
  1313. ; ===============================================================================================================================
  1314. Func _IEFormImageClick(ByRef $oObject, $sLinkText, $sMode = "src", $iIndex = 0, $iWait = 1)
  1315. If Not IsObj($oObject) Then
  1316. __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_InvalidDataType")
  1317. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1318. EndIf
  1319. ;
  1320. Local $sModeLinktext, $iFound = 0
  1321. Local $oTemp = _IEDocGetObj($oObject)
  1322. Local $oImgs = _IETagNameGetCollection($oTemp, "input")
  1323. $sMode = StringLower($sMode)
  1324. $iIndex = Number($iIndex)
  1325. For $oImg In $oImgs
  1326. If String($oImg.type) = "image" Then
  1327. Select
  1328. Case $sMode = "alt"
  1329. $sModeLinktext = $oImg.alt
  1330. Case $sMode = "name"
  1331. $sModeLinktext = $oImg.name
  1332. If Not IsString($sModeLinktext) Then $sModeLinktext = $oImg.id ; html5 support
  1333. Case $sMode = "id"
  1334. $sModeLinktext = $oImg.id
  1335. Case $sMode = "src"
  1336. $sModeLinktext = $oImg.src
  1337. Case Else
  1338. __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_InvalidValue", "Invalid mode: " & $sMode)
  1339. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1340. EndSelect
  1341. If StringInStr($sModeLinktext, $sLinkText) Then
  1342. If ($iFound = $iIndex) Then
  1343. $oImg.click()
  1344. If @error Then ; Trap COM error, report and return
  1345. __IEConsoleWriteError("Error", "_IEFormImageClick", "$_IESTATUS_COMError", @error)
  1346. Return SetError($_IESTATUS_ComError, @error, 0)
  1347. EndIf
  1348. If $iWait Then
  1349. _IELoadWait($oObject)
  1350. Return SetError(@error, 0, -1)
  1351. EndIf
  1352. Return SetError($_IESTATUS_Success, 0, -1)
  1353. EndIf
  1354. $iFound = $iFound + 1
  1355. EndIf
  1356. EndIf
  1357. Next
  1358. __IEConsoleWriteError("Warning", "_IEFormImageClick", "$_IESTATUS_NoMatch")
  1359. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1360. EndFunc ;==>_IEFormImageClick
  1361. ; #FUNCTION# ====================================================================================================================
  1362. ; Author ........: Dale Hohm
  1363. ; ===============================================================================================================================
  1364. Func _IEFormSubmit(ByRef $oObject, $iWait = 1)
  1365. If Not IsObj($oObject) Then
  1366. __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_InvalidDataType")
  1367. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1368. EndIf
  1369. ;
  1370. If Not __IEIsObjType($oObject, "form") Then
  1371. __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_InvalidObjectType")
  1372. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1373. EndIf
  1374. ;
  1375. Local $oWindow = $oObject.document.parentWindow
  1376. $oObject.submit()
  1377. If @error Then ; Trap COM error, report and return
  1378. __IEConsoleWriteError("Error", "_IEFormSubmit", "$_IESTATUS_COMError", @error)
  1379. Return SetError($_IESTATUS_ComError, @error, 0)
  1380. EndIf
  1381. If $iWait Then
  1382. _IELoadWait($oWindow)
  1383. Return SetError(@error, 0, -1)
  1384. EndIf
  1385. Return SetError($_IESTATUS_Success, 0, -1)
  1386. EndFunc ;==>_IEFormSubmit
  1387. ; #FUNCTION# ====================================================================================================================
  1388. ; Author ........: Dale Hohm
  1389. ; ===============================================================================================================================
  1390. Func _IEFormReset(ByRef $oObject)
  1391. If Not IsObj($oObject) Then
  1392. __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_InvalidDataType")
  1393. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1394. EndIf
  1395. ;
  1396. If Not __IEIsObjType($oObject, "form") Then
  1397. __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_InvalidObjectType")
  1398. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1399. EndIf
  1400. ;
  1401. $oObject.reset()
  1402. If @error Then ; Trap COM error, report and return
  1403. __IEConsoleWriteError("Error", "_IEFormReset", "$_IESTATUS_COMError", @error)
  1404. Return SetError($_IESTATUS_ComError, @error, 0)
  1405. EndIf
  1406. Return SetError($_IESTATUS_Success, 0, 1)
  1407. EndFunc ;==>_IEFormReset
  1408. #EndRegion Form functions
  1409. #Region Table functions
  1410. ; #FUNCTION# ====================================================================================================================
  1411. ; Author ........: Dale Hohm
  1412. ; ===============================================================================================================================
  1413. Func _IETableGetCollection(ByRef $oObject, $iIndex = -1)
  1414. If Not IsObj($oObject) Then
  1415. __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidDataType")
  1416. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1417. EndIf
  1418. ;
  1419. $iIndex = Number($iIndex)
  1420. Select
  1421. Case $iIndex = -1
  1422. Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _
  1423. $oObject.document.GetElementsByTagName("table"))
  1424. Case $iIndex > -1 And $iIndex < $oObject.document.GetElementsByTagName("table").length
  1425. Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByTagName("table").length, _
  1426. $oObject.document.GetElementsByTagName("table").item($iIndex))
  1427. Case $iIndex < -1
  1428. __IEConsoleWriteError("Error", "_IETableGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  1429. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  1430. Case Else
  1431. __IEConsoleWriteError("Warning", "_IETableGetCollection", "$_IESTATUS_NoMatch")
  1432. Return SetError($_IESTATUS_NoMatch, 1, 0)
  1433. EndSelect
  1434. EndFunc ;==>_IETableGetCollection
  1435. ; #FUNCTION# ====================================================================================================================
  1436. ; Author ........: Dale Hohm
  1437. ; ===============================================================================================================================
  1438. Func _IETableWriteToArray(ByRef $oObject, $bTranspose = False)
  1439. If Not IsObj($oObject) Then
  1440. __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_InvalidDataType")
  1441. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1442. EndIf
  1443. ;
  1444. If Not __IEIsObjType($oObject, "table") Then
  1445. __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_InvalidObjectType")
  1446. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1447. EndIf
  1448. ;
  1449. Local $iCols = 0, $oTds, $iCol
  1450. Local $oTrs = $oObject.rows
  1451. For $oTr In $oTrs
  1452. $oTds = $oTr.cells
  1453. $iCol = 0
  1454. For $oTd In $oTds
  1455. $iCol = $iCol + $oTd.colSpan
  1456. Next
  1457. If $iCol > $iCols Then $iCols = $iCol
  1458. Next
  1459. Local $iRows = $oTrs.length
  1460. Local $aTableCells[$iCols][$iRows]
  1461. Local $iRow = 0
  1462. For $oTr In $oTrs
  1463. $oTds = $oTr.cells
  1464. $iCol = 0
  1465. For $oTd In $oTds
  1466. $aTableCells[$iCol][$iRow] = String($oTd.innerText)
  1467. If @error Then ; Trap COM error, report and return
  1468. __IEConsoleWriteError("Error", "_IETableWriteToArray", "$_IESTATUS_COMError", @error)
  1469. Return SetError($_IESTATUS_ComError, @error, 0)
  1470. EndIf
  1471. $iCol = $iCol + $oTd.colSpan
  1472. Next
  1473. $iRow = $iRow + 1
  1474. Next
  1475. If $bTranspose Then
  1476. Local $iD1 = UBound($aTableCells, $UBOUND_ROWS), $iD2 = UBound($aTableCells, $UBOUND_COLUMNS), $aTmp[$iD2][$iD1]
  1477. For $i = 0 To $iD2 - 1
  1478. For $j = 0 To $iD1 - 1
  1479. $aTmp[$i][$j] = $aTableCells[$j][$i]
  1480. Next
  1481. Next
  1482. $aTableCells = $aTmp
  1483. EndIf
  1484. Return SetError($_IESTATUS_Success, 0, $aTableCells)
  1485. EndFunc ;==>_IETableWriteToArray
  1486. #EndRegion Table functions
  1487. #Region Read/Write functions
  1488. ; #FUNCTION# ====================================================================================================================
  1489. ; Author ........: Dale Hohm
  1490. ; ===============================================================================================================================
  1491. Func _IEBodyReadHTML(ByRef $oObject)
  1492. If Not IsObj($oObject) Then
  1493. __IEConsoleWriteError("Error", "_IEBodyReadHTML", "$_IESTATUS_InvalidDataType")
  1494. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1495. EndIf
  1496. ;
  1497. Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerHTML)
  1498. EndFunc ;==>_IEBodyReadHTML
  1499. ; #FUNCTION# ====================================================================================================================
  1500. ; Author ........: Dale Hohm
  1501. ; ===============================================================================================================================
  1502. Func _IEBodyReadText(ByRef $oObject)
  1503. If Not IsObj($oObject) Then
  1504. __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidDataType")
  1505. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1506. EndIf
  1507. If Not __IEIsObjType($oObject, "browserdom") Then
  1508. __IEConsoleWriteError("Error", "_IEBodyReadText", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1509. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1510. EndIf
  1511. ;
  1512. Return SetError($_IESTATUS_Success, 0, $oObject.document.body.innerText)
  1513. EndFunc ;==>_IEBodyReadText
  1514. ; #FUNCTION# ====================================================================================================================
  1515. ; Author ........: Dale Hohm
  1516. ; ===============================================================================================================================
  1517. Func _IEBodyWriteHTML(ByRef $oObject, $sHTML)
  1518. If Not IsObj($oObject) Then
  1519. __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_InvalidDataType")
  1520. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1521. EndIf
  1522. If Not __IEIsObjType($oObject, "browserdom") Then
  1523. __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1524. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1525. EndIf
  1526. ;
  1527. $oObject.document.body.innerHTML = $sHTML
  1528. If @error Then ; Trap COM error, report and return
  1529. __IEConsoleWriteError("Error", "_IEBodyWriteHTML", "$_IESTATUS_COMError", @error)
  1530. Return SetError($_IESTATUS_ComError, @error, 0)
  1531. EndIf
  1532. Local $oTemp = $oObject.document
  1533. _IELoadWait($oTemp)
  1534. Return SetError(@error, 0, -1)
  1535. EndFunc ;==>_IEBodyWriteHTML
  1536. ; #FUNCTION# ====================================================================================================================
  1537. ; Author ........: Dale Hohm
  1538. ; ===============================================================================================================================
  1539. Func _IEDocReadHTML(ByRef $oObject)
  1540. If Not IsObj($oObject) Then
  1541. __IEConsoleWriteError("Error", "_IEDocReadHTML", "$_IESTATUS_InvalidDataType")
  1542. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1543. EndIf
  1544. If Not __IEIsObjType($oObject, "browserdom") Then
  1545. __IEConsoleWriteError("Error", "_IEDocReadHTML", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1546. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1547. EndIf
  1548. ;
  1549. Return SetError($_IESTATUS_Success, 0, $oObject.document.documentElement.outerHTML)
  1550. EndFunc ;==>_IEDocReadHTML
  1551. ; #FUNCTION# ====================================================================================================================
  1552. ; Author ........: Dale Hohm
  1553. ; ===============================================================================================================================
  1554. Func _IEDocWriteHTML(ByRef $oObject, $sHTML)
  1555. If Not IsObj($oObject) Then
  1556. __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_InvalidDataType")
  1557. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1558. EndIf
  1559. If Not __IEIsObjType($oObject, "browserdom") Then
  1560. __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1561. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1562. EndIf
  1563. ;
  1564. $oObject.document.Write($sHTML)
  1565. $oObject.document.close()
  1566. Local $oTemp = $oObject.document
  1567. If @error Then ; Trap COM error, report and return
  1568. __IEConsoleWriteError("Error", "_IEDocWriteHTML", "$_IESTATUS_COMError", @error)
  1569. Return SetError($_IESTATUS_ComError, @error, 0)
  1570. EndIf
  1571. _IELoadWait($oTemp)
  1572. Return SetError(@error, 0, -1)
  1573. EndFunc ;==>_IEDocWriteHTML
  1574. ; #FUNCTION# ====================================================================================================================
  1575. ; Author ........: Dale Hohm
  1576. ; ===============================================================================================================================
  1577. Func _IEDocInsertText(ByRef $oObject, $sString, $sWhere = "beforeend")
  1578. If Not IsObj($oObject) Then
  1579. __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidDataType")
  1580. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1581. EndIf
  1582. If Not __IEIsObjType($oObject, "browserdom") Or __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  1583. __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1584. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1585. EndIf
  1586. $sWhere = StringLower($sWhere)
  1587. Select
  1588. Case $sWhere = "beforebegin"
  1589. $oObject.insertAdjacentText($sWhere, $sString)
  1590. Case $sWhere = "afterbegin"
  1591. $oObject.insertAdjacentText($sWhere, $sString)
  1592. Case $sWhere = "beforeend"
  1593. $oObject.insertAdjacentText($sWhere, $sString)
  1594. Case $sWhere = "afterend"
  1595. $oObject.insertAdjacentText($sWhere, $sString)
  1596. Case Else
  1597. ; Unsupported Where
  1598. __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_InvalidValue", "Invalid where value")
  1599. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1600. EndSelect
  1601. If @error Then ; Trap COM error, report and return
  1602. __IEConsoleWriteError("Error", "_IEDocInsertText", "$_IESTATUS_COMError", @error)
  1603. Return SetError($_IESTATUS_ComError, @error, 0)
  1604. EndIf
  1605. Return SetError($_IESTATUS_Success, 0, 1)
  1606. EndFunc ;==>_IEDocInsertText
  1607. ; #FUNCTION# ====================================================================================================================
  1608. ; Author ........: Dale Hohm
  1609. ; ===============================================================================================================================
  1610. Func _IEDocInsertHTML(ByRef $oObject, $sString, $sWhere = "beforeend")
  1611. If Not IsObj($oObject) Then
  1612. __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidDataType")
  1613. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1614. EndIf
  1615. If Not __IEIsObjType($oObject, "browserdom") Or __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  1616. __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidObjectType", "Expected document element")
  1617. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1618. EndIf
  1619. $sWhere = StringLower($sWhere)
  1620. Select
  1621. Case $sWhere = "beforebegin"
  1622. $oObject.insertAdjacentHTML($sWhere, $sString)
  1623. Case $sWhere = "afterbegin"
  1624. $oObject.insertAdjacentHTML($sWhere, $sString)
  1625. Case $sWhere = "beforeend"
  1626. $oObject.insertAdjacentHTML($sWhere, $sString)
  1627. Case $sWhere = "afterend"
  1628. $oObject.insertAdjacentHTML($sWhere, $sString)
  1629. Case Else
  1630. ; Unsupported Where
  1631. __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_InvalidValue", "Invalid where value")
  1632. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1633. EndSelect
  1634. If @error Then ; Trap COM error, report and return
  1635. __IEConsoleWriteError("Error", "_IEDocInsertHTML", "$_IESTATUS_COMError", @error)
  1636. Return SetError($_IESTATUS_ComError, @error, 0)
  1637. EndIf
  1638. Return SetError($_IESTATUS_Success, 0, 1)
  1639. EndFunc ;==>_IEDocInsertHTML
  1640. ; #FUNCTION# ====================================================================================================================
  1641. ; Author ........: Dale Hohm
  1642. ; Modified ......: jpm
  1643. ; ===============================================================================================================================
  1644. Func _IEHeadInsertEventScript(ByRef $oObject, $sHTMLFor, $sEvent, $sScript)
  1645. If Not IsObj($oObject) Then
  1646. __IEConsoleWriteError("Error", "_IEHeadInsertEventScript", "$_IESTATUS_InvalidDataType")
  1647. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1648. EndIf
  1649. Local $oHead = $oObject.document.all.tags("HEAD").Item(0)
  1650. Local $oScript = $oObject.document.createElement("script")
  1651. If @error Then ; Trap COM error, report and return
  1652. __IEConsoleWriteError("Error", "_IEHeadInsertEventScript(script)", "$_IESTATUS_COMError", @error)
  1653. Return SetError($_IESTATUS_ComError, @error, 0)
  1654. EndIf
  1655. With $oScript
  1656. .defer = True
  1657. .language = "jscript"
  1658. .type = "text/javascript"
  1659. .htmlFor = $sHTMLFor
  1660. .event = $sEvent
  1661. .text = $sScript
  1662. EndWith
  1663. $oHead.appendChild($oScript)
  1664. If @error Then ; Trap COM error, report and return
  1665. __IEConsoleWriteError("Error", "_IEHeadInsertEventScript", "$_IESTATUS_COMError", @error)
  1666. Return SetError($_IESTATUS_ComError, @error, 0)
  1667. EndIf
  1668. Return SetError($_IESTATUS_Success, 0, 1)
  1669. EndFunc ;==>_IEHeadInsertEventScript
  1670. #EndRegion Read/Write functions
  1671. #Region Utility functions
  1672. ; #FUNCTION# ====================================================================================================================
  1673. ; Author ........: Dale Hohm
  1674. ; ===============================================================================================================================
  1675. Func _IEDocGetObj(ByRef $oObject)
  1676. If Not IsObj($oObject) Then
  1677. __IEConsoleWriteError("Error", "_IEDocGetObj", "$_IESTATUS_InvalidDataType")
  1678. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1679. EndIf
  1680. ;
  1681. If __IEIsObjType($oObject, "document") Then
  1682. Return SetError($_IESTATUS_Success, 0, $oObject)
  1683. EndIf
  1684. Return SetError($_IESTATUS_Success, 0, $oObject.document)
  1685. EndFunc ;==>_IEDocGetObj
  1686. ; #FUNCTION# ====================================================================================================================
  1687. ; Author ........: Dale Hohm
  1688. ; ===============================================================================================================================
  1689. Func _IETagNameGetCollection(ByRef $oObject, $sTagName, $iIndex = -1)
  1690. If Not IsObj($oObject) Then
  1691. __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidDataType")
  1692. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1693. EndIf
  1694. ;
  1695. If Not __IEIsObjType($oObject, "browserdom") Then
  1696. __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidObjectType")
  1697. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1698. EndIf
  1699. Local $oTemp
  1700. If __IEIsObjType($oObject, "documentcontainer") Then
  1701. $oTemp = _IEDocGetObj($oObject)
  1702. Else
  1703. $oTemp = $oObject
  1704. EndIf
  1705. $iIndex = Number($iIndex)
  1706. Select
  1707. Case $iIndex = -1
  1708. Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, _
  1709. $oTemp.GetElementsByTagName($sTagName))
  1710. Case $iIndex > -1 And $iIndex < $oTemp.GetElementsByTagName($sTagName).length
  1711. Return SetError($_IESTATUS_Success, $oTemp.GetElementsByTagName($sTagName).length, _
  1712. $oTemp.GetElementsByTagName($sTagName).item($iIndex))
  1713. Case $iIndex < -1
  1714. __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  1715. Return SetError($_IESTATUS_InvalidValue, 3, 0)
  1716. Case Else
  1717. __IEConsoleWriteError("Error", "_IETagNameGetCollection", "$_IESTATUS_NoMatch")
  1718. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
  1719. EndSelect
  1720. EndFunc ;==>_IETagNameGetCollection
  1721. ; #FUNCTION# ====================================================================================================================
  1722. ; Author ........: Dale Hohm
  1723. ; ===============================================================================================================================
  1724. Func _IETagNameAllGetCollection(ByRef $oObject, $iIndex = -1)
  1725. If Not IsObj($oObject) Then
  1726. __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidDataType")
  1727. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1728. EndIf
  1729. ;
  1730. If Not __IEIsObjType($oObject, "browserdom") Then
  1731. __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidObjectType")
  1732. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1733. EndIf
  1734. Local $oTemp
  1735. If __IEIsObjType($oObject, "documentcontainer") Then
  1736. $oTemp = _IEDocGetObj($oObject)
  1737. Else
  1738. $oTemp = $oObject
  1739. EndIf
  1740. $iIndex = Number($iIndex)
  1741. Select
  1742. Case $iIndex = -1
  1743. Return SetError($_IESTATUS_Success, $oTemp.all.length, $oTemp.all)
  1744. Case $iIndex > -1 And $iIndex < $oTemp.all.length
  1745. Return SetError($_IESTATUS_Success, $oTemp.all.length, $oTemp.all.item($iIndex))
  1746. Case $iIndex < -1
  1747. __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_InvalidValue", "$iIndex < -1")
  1748. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  1749. Case Else
  1750. __IEConsoleWriteError("Error", "_IETagNameAllGetCollection", "$_IESTATUS_NoMatch")
  1751. Return SetError($_IESTATUS_NoMatch, 1, 0)
  1752. EndSelect
  1753. EndFunc ;==>_IETagNameAllGetCollection
  1754. ; #FUNCTION# ====================================================================================================================
  1755. ; Author ........: Dale Hohm
  1756. ; ===============================================================================================================================
  1757. Func _IEGetObjByName(ByRef $oObject, $sName, $iIndex = 0)
  1758. If Not IsObj($oObject) Then
  1759. __IEConsoleWriteError("Error", "_IEGetObjByName", "$_IESTATUS_InvalidDataType")
  1760. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1761. EndIf
  1762. ;
  1763. $iIndex = Number($iIndex)
  1764. If $iIndex = -1 Then
  1765. Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByName($sName).length, _
  1766. $oObject.document.GetElementsByName($sName))
  1767. Else
  1768. If IsObj($oObject.document.GetElementsByName($sName).item($iIndex)) Then
  1769. Return SetError($_IESTATUS_Success, $oObject.document.GetElementsByName($sName).length, _
  1770. $oObject.document.GetElementsByName($sName).item($iIndex))
  1771. Else
  1772. __IEConsoleWriteError("Warning", "_IEGetObjByName", "$_IESTATUS_NoMatch", "Name: " & $sName & ", Index: " & $iIndex)
  1773. Return SetError($_IESTATUS_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both
  1774. EndIf
  1775. EndIf
  1776. EndFunc ;==>_IEGetObjByName
  1777. ; #FUNCTION# ====================================================================================================================
  1778. ; Author ........: Dale Hohm
  1779. ; ===============================================================================================================================
  1780. Func _IEGetObjById(ByRef $oObject, $sID)
  1781. If Not IsObj($oObject) Then
  1782. __IEConsoleWriteError("Error", "_IEGetObjById", "$_IESTATUS_InvalidDataType")
  1783. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1784. EndIf
  1785. ;
  1786. If Not __IEIsObjType($oObject, "browserdom") Then
  1787. __IEConsoleWriteError("Error", "_IEGetObById", "$_IESTATUS_InvalidObjectType")
  1788. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1789. EndIf
  1790. ;
  1791. If IsObj($oObject.document.getElementById($sID)) Then
  1792. Return SetError($_IESTATUS_Success, 0, $oObject.document.getElementById($sID))
  1793. Else
  1794. __IEConsoleWriteError("Warning", "_IEGetObjById", "$_IESTATUS_NoMatch", $sID)
  1795. Return SetError($_IESTATUS_NoMatch, 2, 0)
  1796. EndIf
  1797. EndFunc ;==>_IEGetObjById
  1798. ; #FUNCTION# ====================================================================================================================
  1799. ; Author ........: Dale Hohm
  1800. ; ===============================================================================================================================
  1801. Func _IEAction(ByRef $oObject, $sAction)
  1802. If Not IsObj($oObject) Then
  1803. __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_InvalidDataType")
  1804. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1805. EndIf
  1806. ;
  1807. $sAction = StringLower($sAction)
  1808. Select
  1809. ; DOM objects
  1810. Case $sAction = "click"
  1811. If __IEIsObjType($oObject, "documentContainer") Then
  1812. __IEConsoleWriteError("Error", "_IEAction(click)", " $_IESTATUS_InvalidObjectType")
  1813. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1814. EndIf
  1815. $oObject.Click()
  1816. Case $sAction = "disable"
  1817. If __IEIsObjType($oObject, "documentContainer") Then
  1818. __IEConsoleWriteError("Error", "_IEAction(disable)", " $_IESTATUS_InvalidObjectType")
  1819. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1820. EndIf
  1821. $oObject.disabled = True
  1822. Case $sAction = "enable"
  1823. If __IEIsObjType($oObject, "documentContainer") Then
  1824. __IEConsoleWriteError("Error", "_IEAction(enable)", " $_IESTATUS_InvalidObjectType")
  1825. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1826. EndIf
  1827. $oObject.disabled = False
  1828. Case $sAction = "focus"
  1829. If __IEIsObjType($oObject, "documentContainer") Then
  1830. __IEConsoleWriteError("Error", "_IEAction(focus)", "$_IESTATUS_InvalidObjectType")
  1831. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1832. EndIf
  1833. $oObject.Focus()
  1834. Case $sAction = "scrollintoview"
  1835. If __IEIsObjType($oObject, "documentContainer") Then
  1836. __IEConsoleWriteError("Error", "_IEAction(scrollintoview)", "$_IESTATUS_InvalidObjectType")
  1837. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1838. EndIf
  1839. $oObject.scrollIntoView()
  1840. ; Browser Object
  1841. Case $sAction = "copy"
  1842. $oObject.document.execCommand("Copy")
  1843. Case $sAction = "cut"
  1844. $oObject.document.execCommand("Cut")
  1845. Case $sAction = "paste"
  1846. $oObject.document.execCommand("Paste")
  1847. Case $sAction = "delete"
  1848. $oObject.document.execCommand("Delete")
  1849. Case $sAction = "saveas"
  1850. $oObject.document.execCommand("SaveAs")
  1851. Case $sAction = "refresh"
  1852. $oObject.document.execCommand("Refresh")
  1853. If @error Then ; Trap COM error, report and return
  1854. __IEConsoleWriteError("Error", "_IEAction(refresh)", "$_IESTATUS_COMError", @error)
  1855. Return SetError($_IESTATUS_ComError, @error, 0)
  1856. EndIf
  1857. _IELoadWait($oObject)
  1858. Case $sAction = "selectall"
  1859. $oObject.document.execCommand("SelectAll")
  1860. Case $sAction = "unselect"
  1861. $oObject.document.execCommand("Unselect")
  1862. Case $sAction = "print"
  1863. $oObject.document.parentwindow.Print()
  1864. Case $sAction = "printdefault"
  1865. If Not __IEIsObjType($oObject, "browser") Then
  1866. __IEConsoleWriteError("Error", "_IEAction(printdefault)", "$_IESTATUS_InvalidObjectType")
  1867. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1868. EndIf
  1869. $oObject.execWB(6, 2)
  1870. Case $sAction = "back"
  1871. If Not __IEIsObjType($oObject, "documentContainer") Then
  1872. __IEConsoleWriteError("Error", "_IEAction(back)", "$_IESTATUS_InvalidObjectType")
  1873. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1874. EndIf
  1875. $oObject.GoBack()
  1876. Case $sAction = "blur"
  1877. $oObject.Blur()
  1878. Case $sAction = "forward"
  1879. If Not __IEIsObjType($oObject, "documentContainer") Then
  1880. __IEConsoleWriteError("Error", "_IEAction(forward)", "$_IESTATUS_InvalidObjectType")
  1881. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1882. EndIf
  1883. $oObject.GoForward()
  1884. Case $sAction = "home"
  1885. If Not __IEIsObjType($oObject, "documentContainer") Then
  1886. __IEConsoleWriteError("Error", "_IEAction(home)", "$_IESTATUS_InvalidObjectType")
  1887. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1888. EndIf
  1889. $oObject.GoHome()
  1890. Case $sAction = "invisible"
  1891. If Not __IEIsObjType($oObject, "browser") Then
  1892. __IEConsoleWriteError("Error", "_IEAction(invisible)", "$_IESTATUS_InvalidObjectType")
  1893. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1894. EndIf
  1895. $oObject.visible = 0
  1896. Case $sAction = "visible"
  1897. If Not __IEIsObjType($oObject, "browser") Then
  1898. __IEConsoleWriteError("Error", "_IEAction(visible)", "$_IESTATUS_InvalidObjectType")
  1899. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1900. EndIf
  1901. $oObject.visible = 1
  1902. Case $sAction = "search"
  1903. If Not __IEIsObjType($oObject, "browser") Then
  1904. __IEConsoleWriteError("Error", "_IEAction(search)", "$_IESTATUS_InvalidObjectType")
  1905. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1906. EndIf
  1907. $oObject.GoSearch()
  1908. Case $sAction = "stop"
  1909. If Not __IEIsObjType($oObject, "documentContainer") Then
  1910. __IEConsoleWriteError("Error", "_IEAction(stop)", "$_IESTATUS_InvalidObjectType")
  1911. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1912. EndIf
  1913. $oObject.Stop()
  1914. Case $sAction = "quit"
  1915. If Not __IEIsObjType($oObject, "browser") Then
  1916. __IEConsoleWriteError("Error", "_IEAction(quit)", "$_IESTATUS_InvalidObjectType")
  1917. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1918. EndIf
  1919. $oObject.Quit()
  1920. If @error Then ; Trap COM error, report and return
  1921. __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error)
  1922. Return SetError($_IESTATUS_ComError, @error, 0)
  1923. EndIf
  1924. $oObject = 0
  1925. Return SetError($_IESTATUS_Success, 0, 1)
  1926. Case Else
  1927. ; Unsupported Action
  1928. __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_InvalidValue", "Invalid Action")
  1929. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  1930. EndSelect
  1931. If @error Then ; Trap COM error, report and return
  1932. __IEConsoleWriteError("Error", "_IEAction(" & $sAction & ")", "$_IESTATUS_COMError", @error)
  1933. Return SetError($_IESTATUS_ComError, @error, 0)
  1934. EndIf
  1935. Return SetError($_IESTATUS_Success, 0, 1)
  1936. EndFunc ;==>_IEAction
  1937. ; #FUNCTION# ====================================================================================================================
  1938. ; Author ........: Dale Hohm
  1939. ; ===============================================================================================================================
  1940. Func _IEPropertyGet(ByRef $oObject, $sProperty)
  1941. If Not IsObj($oObject) Then
  1942. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidDataType")
  1943. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  1944. EndIf
  1945. If Not __IEIsObjType($oObject, "browserdom") Then
  1946. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  1947. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1948. EndIf
  1949. ;
  1950. Local $oTemp, $iTemp
  1951. $sProperty = StringLower($sProperty)
  1952. Select
  1953. Case $sProperty = "browserx"
  1954. If __IEIsObjType($oObject, "browsercontainer") Or __IEIsObjType($oObject, "document") Then
  1955. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  1956. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1957. EndIf
  1958. $oTemp = $oObject
  1959. $iTemp = 0
  1960. While IsObj($oTemp)
  1961. $iTemp += $oTemp.offsetLeft
  1962. $oTemp = $oTemp.offsetParent
  1963. WEnd
  1964. Return SetError($_IESTATUS_Success, 0, $iTemp)
  1965. Case $sProperty = "browsery"
  1966. If __IEIsObjType($oObject, "browsercontainer") Or __IEIsObjType($oObject, "document") Then
  1967. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  1968. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1969. EndIf
  1970. $oTemp = $oObject
  1971. $iTemp = 0
  1972. While IsObj($oTemp)
  1973. $iTemp += $oTemp.offsetTop
  1974. $oTemp = $oTemp.offsetParent
  1975. WEnd
  1976. Return SetError($_IESTATUS_Success, 0, $iTemp)
  1977. Case $sProperty = "screenx"
  1978. If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then
  1979. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  1980. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1981. EndIf
  1982. If __IEIsObjType($oObject, "browser") Then
  1983. Return SetError($_IESTATUS_Success, 0, $oObject.left())
  1984. Else
  1985. $oTemp = $oObject
  1986. $iTemp = 0
  1987. While IsObj($oTemp)
  1988. $iTemp += $oTemp.offsetLeft
  1989. $oTemp = $oTemp.offsetParent
  1990. WEnd
  1991. EndIf
  1992. Return SetError($_IESTATUS_Success, 0, _
  1993. $iTemp + $oObject.document.parentWindow.screenLeft)
  1994. Case $sProperty = "screeny"
  1995. If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then
  1996. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  1997. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  1998. EndIf
  1999. If __IEIsObjType($oObject, "browser") Then
  2000. Return SetError($_IESTATUS_Success, 0, $oObject.top())
  2001. Else
  2002. $oTemp = $oObject
  2003. $iTemp = 0
  2004. While IsObj($oTemp)
  2005. $iTemp += $oTemp.offsetTop
  2006. $oTemp = $oTemp.offsetParent
  2007. WEnd
  2008. EndIf
  2009. Return SetError($_IESTATUS_Success, 0, _
  2010. $iTemp + $oObject.document.parentWindow.screenTop)
  2011. Case $sProperty = "height"
  2012. If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then
  2013. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2014. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2015. EndIf
  2016. If __IEIsObjType($oObject, "browser") Then
  2017. Return SetError($_IESTATUS_Success, 0, $oObject.Height())
  2018. Else
  2019. Return SetError($_IESTATUS_Success, 0, $oObject.offsetHeight)
  2020. EndIf
  2021. Case $sProperty = "width"
  2022. If __IEIsObjType($oObject, "window") Or __IEIsObjType($oObject, "document") Then
  2023. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2024. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2025. EndIf
  2026. If __IEIsObjType($oObject, "browser") Then
  2027. Return SetError($_IESTATUS_Success, 0, $oObject.Width())
  2028. Else
  2029. Return SetError($_IESTATUS_Success, 0, $oObject.offsetWidth)
  2030. EndIf
  2031. Case $sProperty = "isdisabled"
  2032. Return SetError($_IESTATUS_Success, 0, $oObject.isDisabled())
  2033. Case $sProperty = "addressbar"
  2034. If Not __IEIsObjType($oObject, "browser") Then
  2035. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2036. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2037. EndIf
  2038. Return SetError($_IESTATUS_Success, 0, $oObject.AddressBar())
  2039. Case $sProperty = "busy"
  2040. If Not __IEIsObjType($oObject, "browser") Then
  2041. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2042. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2043. EndIf
  2044. Return SetError($_IESTATUS_Success, 0, $oObject.Busy())
  2045. Case $sProperty = "fullscreen"
  2046. If Not __IEIsObjType($oObject, "browser") Then
  2047. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2048. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2049. EndIf
  2050. Return SetError($_IESTATUS_Success, 0, $oObject.fullScreen())
  2051. Case $sProperty = "hwnd"
  2052. If Not __IEIsObjType($oObject, "browser") Then
  2053. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2054. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2055. EndIf
  2056. Return SetError($_IESTATUS_Success, 0, HWnd($oObject.HWnd()))
  2057. Case $sProperty = "left"
  2058. If Not __IEIsObjType($oObject, "browser") Then
  2059. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2060. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2061. EndIf
  2062. Return SetError($_IESTATUS_Success, 0, $oObject.Left())
  2063. Case $sProperty = "locationname"
  2064. If Not __IEIsObjType($oObject, "browser") Then
  2065. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2066. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2067. EndIf
  2068. Return SetError($_IESTATUS_Success, 0, $oObject.LocationName())
  2069. Case $sProperty = "locationurl"
  2070. If __IEIsObjType($oObject, "browser") Then
  2071. Return SetError($_IESTATUS_Success, 0, $oObject.locationURL())
  2072. EndIf
  2073. If __IEIsObjType($oObject, "window") Then
  2074. Return SetError($_IESTATUS_Success, 0, $oObject.location.href())
  2075. EndIf
  2076. If __IEIsObjType($oObject, "document") Then
  2077. Return SetError($_IESTATUS_Success, 0, $oObject.parentwindow.location.href())
  2078. EndIf
  2079. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentwindow.location.href())
  2080. Case $sProperty = "menubar"
  2081. If Not __IEIsObjType($oObject, "browser") Then
  2082. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2083. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2084. EndIf
  2085. Return SetError($_IESTATUS_Success, 0, $oObject.MenuBar())
  2086. Case $sProperty = "offline"
  2087. If Not __IEIsObjType($oObject, "browser") Then
  2088. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2089. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2090. EndIf
  2091. Return SetError($_IESTATUS_Success, 0, $oObject.OffLine())
  2092. Case $sProperty = "readystate"
  2093. If Not __IEIsObjType($oObject, "browser") Then
  2094. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2095. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2096. EndIf
  2097. Return SetError($_IESTATUS_Success, 0, $oObject.ReadyState())
  2098. Case $sProperty = "resizable"
  2099. If Not __IEIsObjType($oObject, "browser") Then
  2100. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2101. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2102. EndIf
  2103. Return SetError($_IESTATUS_Success, 0, $oObject.Resizable())
  2104. Case $sProperty = "silent"
  2105. If Not __IEIsObjType($oObject, "browser") Then
  2106. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2107. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2108. EndIf
  2109. Return SetError($_IESTATUS_Success, 0, $oObject.Silent())
  2110. Case $sProperty = "statusbar"
  2111. If Not __IEIsObjType($oObject, "browser") Then
  2112. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2113. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2114. EndIf
  2115. Return SetError($_IESTATUS_Success, 0, $oObject.StatusBar())
  2116. Case $sProperty = "statustext"
  2117. If Not __IEIsObjType($oObject, "browser") Then
  2118. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2119. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2120. EndIf
  2121. Return SetError($_IESTATUS_Success, 0, $oObject.StatusText())
  2122. Case $sProperty = "top"
  2123. If Not __IEIsObjType($oObject, "browser") Then
  2124. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2125. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2126. EndIf
  2127. Return SetError($_IESTATUS_Success, 0, $oObject.Top())
  2128. Case $sProperty = "visible"
  2129. If Not __IEIsObjType($oObject, "browser") Then
  2130. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2131. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2132. EndIf
  2133. Return SetError($_IESTATUS_Success, 0, $oObject.Visible())
  2134. Case $sProperty = "appcodename"
  2135. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appCodeName())
  2136. Case $sProperty = "appminorversion"
  2137. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appMinorVersion())
  2138. Case $sProperty = "appname"
  2139. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appName())
  2140. Case $sProperty = "appversion"
  2141. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.appVersion())
  2142. Case $sProperty = "browserlanguage"
  2143. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.browserLanguage())
  2144. Case $sProperty = "cookieenabled"
  2145. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.cookieEnabled())
  2146. Case $sProperty = "cpuclass"
  2147. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.cpuClass())
  2148. Case $sProperty = "javaenabled"
  2149. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.javaEnabled())
  2150. Case $sProperty = "online"
  2151. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.onLine())
  2152. Case $sProperty = "platform"
  2153. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.platform())
  2154. Case $sProperty = "systemlanguage"
  2155. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.systemLanguage())
  2156. Case $sProperty = "useragent"
  2157. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.userAgent())
  2158. Case $sProperty = "userlanguage"
  2159. Return SetError($_IESTATUS_Success, 0, $oObject.document.parentWindow.top.navigator.userLanguage())
  2160. Case $sProperty = "referrer"
  2161. Return SetError($_IESTATUS_Success, 0, $oObject.document.referrer)
  2162. Case $sProperty = "theatermode"
  2163. If Not __IEIsObjType($oObject, "browser") Then
  2164. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2165. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2166. EndIf
  2167. Return SetError($_IESTATUS_Success, 0, $oObject.TheaterMode)
  2168. Case $sProperty = "toolbar"
  2169. If Not __IEIsObjType($oObject, "browser") Then
  2170. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2171. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2172. EndIf
  2173. Return SetError($_IESTATUS_Success, 0, $oObject.ToolBar)
  2174. Case $sProperty = "contenteditable"
  2175. If __IEIsObjType($oObject, "browser") Or __IEIsObjType($oObject, "document") Then
  2176. $oTemp = $oObject.document.body
  2177. Else
  2178. $oTemp = $oObject
  2179. EndIf
  2180. Return SetError($_IESTATUS_Success, 0, $oTemp.isContentEditable)
  2181. Case $sProperty = "innertext"
  2182. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2183. $oTemp = $oObject.document.body
  2184. Else
  2185. $oTemp = $oObject
  2186. EndIf
  2187. Return SetError($_IESTATUS_Success, 0, $oTemp.innerText)
  2188. Case $sProperty = "outertext"
  2189. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2190. $oTemp = $oObject.document.body
  2191. Else
  2192. $oTemp = $oObject
  2193. EndIf
  2194. Return SetError($_IESTATUS_Success, 0, $oTemp.outerText)
  2195. Case $sProperty = "innerhtml"
  2196. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2197. $oTemp = $oObject.document.body
  2198. Else
  2199. $oTemp = $oObject
  2200. EndIf
  2201. Return SetError($_IESTATUS_Success, 0, $oTemp.innerHTML)
  2202. Case $sProperty = "outerhtml"
  2203. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2204. $oTemp = $oObject.document.body
  2205. Else
  2206. $oTemp = $oObject
  2207. EndIf
  2208. Return SetError($_IESTATUS_Success, 0, $oTemp.outerHTML)
  2209. Case $sProperty = "title"
  2210. Return SetError($_IESTATUS_Success, 0, $oObject.document.title)
  2211. Case $sProperty = "uniqueid"
  2212. If __IEIsObjType($oObject, "window") Then
  2213. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidObjectType")
  2214. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2215. Else
  2216. Return SetError($_IESTATUS_Success, 0, $oObject.uniqueID)
  2217. EndIf
  2218. Case Else
  2219. ; Unsupported Property
  2220. __IEConsoleWriteError("Error", "_IEPropertyGet", "$_IESTATUS_InvalidValue", "Invalid Property")
  2221. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  2222. EndSelect
  2223. EndFunc ;==>_IEPropertyGet
  2224. ; #FUNCTION# ====================================================================================================================
  2225. ; Author ........: Dale Hohm
  2226. ; ===============================================================================================================================
  2227. Func _IEPropertySet(ByRef $oObject, $sProperty, $vValue)
  2228. If Not IsObj($oObject) Then
  2229. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidDataType")
  2230. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  2231. EndIf
  2232. ;
  2233. Local $oTemp
  2234. #forceref $oTemp
  2235. $sProperty = StringLower($sProperty)
  2236. Select
  2237. Case $sProperty = "addressbar"
  2238. If Not __IEIsObjType($oObject, "browser") Then
  2239. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2240. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2241. EndIf
  2242. $oObject.AddressBar = $vValue
  2243. Case $sProperty = "height"
  2244. If Not __IEIsObjType($oObject, "browser") Then
  2245. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2246. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2247. EndIf
  2248. $oObject.Height = $vValue
  2249. Case $sProperty = "left"
  2250. If Not __IEIsObjType($oObject, "browser") Then
  2251. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2252. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2253. EndIf
  2254. $oObject.Left = $vValue
  2255. Case $sProperty = "menubar"
  2256. If Not __IEIsObjType($oObject, "browser") Then
  2257. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2258. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2259. EndIf
  2260. $oObject.MenuBar = $vValue
  2261. Case $sProperty = "offline"
  2262. If Not __IEIsObjType($oObject, "browser") Then
  2263. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2264. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2265. EndIf
  2266. $oObject.OffLine = $vValue
  2267. Case $sProperty = "resizable"
  2268. If Not __IEIsObjType($oObject, "browser") Then
  2269. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2270. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2271. EndIf
  2272. $oObject.Resizable = $vValue
  2273. Case $sProperty = "statusbar"
  2274. If Not __IEIsObjType($oObject, "browser") Then
  2275. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2276. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2277. EndIf
  2278. $oObject.StatusBar = $vValue
  2279. Case $sProperty = "statustext"
  2280. If Not __IEIsObjType($oObject, "browser") Then
  2281. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2282. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2283. EndIf
  2284. $oObject.StatusText = $vValue
  2285. Case $sProperty = "top"
  2286. If Not __IEIsObjType($oObject, "browser") Then
  2287. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2288. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2289. EndIf
  2290. $oObject.Top = $vValue
  2291. Case $sProperty = "width"
  2292. If Not __IEIsObjType($oObject, "browser") Then
  2293. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2294. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2295. EndIf
  2296. $oObject.Width = $vValue
  2297. Case $sProperty = "theatermode"
  2298. If Not __IEIsObjType($oObject, "browser") Then
  2299. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2300. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2301. EndIf
  2302. If $vValue Then
  2303. $oObject.TheaterMode = True
  2304. Else
  2305. $oObject.TheaterMode = False
  2306. EndIf
  2307. Case $sProperty = "toolbar"
  2308. If Not __IEIsObjType($oObject, "browser") Then
  2309. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2310. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2311. EndIf
  2312. If $vValue Then
  2313. $oObject.ToolBar = True
  2314. Else
  2315. $oObject.ToolBar = False
  2316. EndIf
  2317. Case $sProperty = "contenteditable"
  2318. If __IEIsObjType($oObject, "browser") Or __IEIsObjType($oObject, "document") Then
  2319. $oTemp = $oObject.document.body
  2320. Else
  2321. $oTemp = $oObject
  2322. EndIf
  2323. If $vValue Then
  2324. $oTemp.contentEditable = "true"
  2325. Else
  2326. $oTemp.contentEditable = "false"
  2327. EndIf
  2328. Case $sProperty = "innertext"
  2329. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2330. $oTemp = $oObject.document.body
  2331. Else
  2332. $oTemp = $oObject
  2333. EndIf
  2334. $oTemp.innerText = $vValue
  2335. Case $sProperty = "outertext"
  2336. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2337. $oTemp = $oObject.document.body
  2338. Else
  2339. $oTemp = $oObject
  2340. EndIf
  2341. $oTemp.outerText = $vValue
  2342. Case $sProperty = "innerhtml"
  2343. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2344. $oTemp = $oObject.document.body
  2345. Else
  2346. $oTemp = $oObject
  2347. EndIf
  2348. $oTemp.innerHTML = $vValue
  2349. Case $sProperty = "outerhtml"
  2350. If __IEIsObjType($oObject, "documentcontainer") Or __IEIsObjType($oObject, "document") Then
  2351. $oTemp = $oObject.document.body
  2352. Else
  2353. $oTemp = $oObject
  2354. EndIf
  2355. $oTemp.outerHTML = $vValue
  2356. Case $sProperty = "title"
  2357. $oObject.document.title = $vValue
  2358. Case $sProperty = "silent"
  2359. If Not __IEIsObjType($oObject, "browser") Then
  2360. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidObjectType")
  2361. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2362. EndIf
  2363. If $vValue Then
  2364. $oObject.silent = True
  2365. Else
  2366. $oObject.silent = False
  2367. EndIf
  2368. Case Else
  2369. ; Unsupported Property
  2370. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_InvalidValue", "Invalid Property")
  2371. Return SetError($_IESTATUS_InvalidValue, 2, 0)
  2372. EndSelect
  2373. If @error Then ; Trap COM error, report and return
  2374. __IEConsoleWriteError("Error", "_IEPropertySet", "$_IESTATUS_COMError", @error)
  2375. Return SetError($_IESTATUS_ComError, @error, 0)
  2376. EndIf
  2377. Return SetError($_IESTATUS_Success, 0, 1)
  2378. EndFunc ;==>_IEPropertySet
  2379. ; #FUNCTION# ====================================================================================================================
  2380. ; Author ........: Dale Hohm
  2381. ; Modified ......: jpm
  2382. ; ===============================================================================================================================
  2383. Func _IEErrorNotify($vNotify = Default)
  2384. If $vNotify = Default Then Return $__g_bIEErrorNotify
  2385. If $vNotify Then
  2386. $__g_bIEErrorNotify = True
  2387. Else
  2388. $__g_bIEErrorNotify = False
  2389. EndIf
  2390. Return 1
  2391. EndFunc ;==>_IEErrorNotify
  2392. ; #NO_DOC_FUNCTION# =============================================================================================================
  2393. ; Name...........: _IEErrorHandlerRegister
  2394. ; Description ...: Register and enable a user COM error handler
  2395. ; Parameters ....: $sFunctionName - String variable with the name of a user-defined COM error handler
  2396. ; defaults to the internal COM error handler in this UDF
  2397. ; Return values .: On Success - Returns 1
  2398. ; On Failure - Returns 0 and sets @error
  2399. ; @error - 0 ($_IEStatus_Success) = No Error
  2400. ; - 1 ($_IEStatus_GeneralError) = General Error
  2401. ; @extended - Contains invalid parameter number
  2402. ; Author ........: Dale Hohm
  2403. ; ===============================================================================================================================
  2404. Func _IEErrorHandlerRegister($sFunctionName = "__IEInternalErrorHandler")
  2405. $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", $sFunctionName)
  2406. If IsObj($__g_oIEErrorHandler) Then
  2407. $__g_sIEUserErrorHandler = $sFunctionName
  2408. Return SetError($_IESTATUS_Success, 0, 1)
  2409. Else
  2410. $__g_oIEErrorHandler = ""
  2411. __IEConsoleWriteError("Error", "_IEErrorHandlerRegister", "$_IEStatus_GeneralError", _
  2412. "Error Handler Not Registered - Check existance of error function")
  2413. Return SetError($_IEStatus_GeneralError, 1, 0)
  2414. EndIf
  2415. EndFunc ;==>_IEErrorHandlerRegister
  2416. ; #NO_DOC_FUNCTION# =============================================================================================================
  2417. ; Name...........: _IEErrorHandlerDeRegister
  2418. ; Description ...: Disable a registered user COM error handler
  2419. ; Parameters ....: None
  2420. ; Return values .: On Success - Returns 1
  2421. ; On Failure - None
  2422. ; Author ........: Dale Hohm
  2423. ; ===============================================================================================================================
  2424. Func _IEErrorHandlerDeRegister()
  2425. $__g_sIEUserErrorHandler = ""
  2426. $__g_oIEErrorHandler = ""
  2427. Return SetError($_IESTATUS_Success, 0, 1)
  2428. EndFunc ;==>_IEErrorHandlerDeRegister
  2429. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2430. ; Name...........: __IEInternalErrorHandlerRegister
  2431. ; Description ...: to be called on error
  2432. ; Author ........: Dale Hohm
  2433. ; Modified ......:
  2434. ; ===============================================================================================================================
  2435. Func __IEInternalErrorHandlerRegister()
  2436. Local $sCurrentErrorHandler = ObjEvent("AutoIt.Error")
  2437. If $sCurrentErrorHandler <> "" And Not IsObj($__g_oIEErrorHandler) Then
  2438. ; We've got trouble... User COM Error handler assigned without using _IEUserErrorHandlerRegister
  2439. Return SetError($_IEStatus_GeneralError, 0, False)
  2440. EndIf
  2441. $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", "__IEInternalErrorHandler")
  2442. If IsObj($__g_oIEErrorHandler) Then
  2443. Return SetError($_IESTATUS_Success, 0, True)
  2444. Else
  2445. $__g_oIEErrorHandler = ""
  2446. Return SetError($_IEStatus_GeneralError, 0, False)
  2447. EndIf
  2448. EndFunc ;==>__IEInternalErrorHandlerRegister
  2449. Func __IEInternalErrorHandlerDeRegister()
  2450. $__g_oIEErrorHandler = ""
  2451. If $__g_sIEUserErrorHandler <> "" Then
  2452. $__g_oIEErrorHandler = ObjEvent("AutoIt.Error", $__g_sIEUserErrorHandler)
  2453. EndIf
  2454. Return SetError($_IESTATUS_Success, 0, 1)
  2455. EndFunc ;==>__IEInternalErrorHandlerDeRegister
  2456. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2457. ; Name...........: __IEInternalErrorHandler
  2458. ; Description ...: to be called on error
  2459. ; Author ........: Dale Hohm
  2460. ; Modified ......:
  2461. ; ===============================================================================================================================
  2462. Func __IEInternalErrorHandler($oCOMError)
  2463. If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF)
  2464. SetError($_IEStatus_ComError)
  2465. Return
  2466. EndFunc ;==>__IEInternalErrorHandler
  2467. ; #FUNCTION# ====================================================================================================================
  2468. ; Author ........: Dale Hohm
  2469. ; ===============================================================================================================================
  2470. Func _IEQuit(ByRef $oObject)
  2471. ;~ Local $sName_IEQuit = String(ObjName($oObject))
  2472. If Not IsObj($oObject) Then
  2473. __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_InvalidDataType")
  2474. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  2475. EndIf
  2476. ;
  2477. If Not __IEIsObjType($oObject, "browser") Then
  2478. __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_InvalidObjectType")
  2479. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  2480. EndIf
  2481. ;
  2482. $oObject.quit()
  2483. If @error Then ; Trap COM error, report and return
  2484. __IEConsoleWriteError("Error", "_IEQuit", "$_IESTATUS_COMError", @error)
  2485. Return SetError($_IESTATUS_ComError, @error, 0)
  2486. EndIf
  2487. $oObject = 0
  2488. Return SetError($_IESTATUS_Success, 0, 1)
  2489. EndFunc ;==>_IEQuit
  2490. #EndRegion Utility functions
  2491. #Region General
  2492. ; #FUNCTION# ====================================================================================================================
  2493. ; Author ........: Dale Hohm
  2494. ; Modified ......: jpm
  2495. ; ===============================================================================================================================
  2496. Func _IE_Introduction($sModule = "basic")
  2497. Local $sHTML = ""
  2498. Switch $sModule
  2499. Case "basic"
  2500. $sHTML &= '<!DOCTYPE html>' & @CR
  2501. $sHTML &= '<html>' & @CR
  2502. $sHTML &= '<head>' & @CR
  2503. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  2504. $sHTML &= '<title>_IE_Introduction ("basic")</title>' & @CR
  2505. $sHTML &= '<style>body {font-family: Arial}' & @CR
  2506. $sHTML &= 'td {padding:6px}</style>' & @CR
  2507. $sHTML &= '</head>' & @CR
  2508. $sHTML &= '<body>' & @CR
  2509. $sHTML &= '<table border=1 id="table1" style="width:600px;border-spacing:6px;">' & @CR
  2510. $sHTML &= '<tr>' & @CR
  2511. $sHTML &= '<td>' & @CR
  2512. $sHTML &= '<h1>Welcome to IE.au3</h1>' & @CR
  2513. $sHTML &= 'IE.au3 is a UDF (User Defined Function) library for the ' & @CR
  2514. $sHTML &= '<a href="http://www.autoitscript.com">AutoIt</a> scripting language.' & @CR
  2515. $sHTML &= '<br> ' & @CR
  2516. $sHTML &= 'IE.au3 allows you to either create or attach to an Internet Explorer browser and do ' & @CR
  2517. $sHTML &= 'just about anything you could do with it interactively with the mouse and ' & @CR
  2518. $sHTML &= 'keyboard, but do it through script.' & @CR
  2519. $sHTML &= '<br>' & @CR
  2520. $sHTML &= 'You can navigate to pages, click links, fill and submit forms etc. You can ' & @CR
  2521. $sHTML &= 'also do things you cannot do interactively like change or rewrite page ' & @CR
  2522. $sHTML &= 'content and JavaScripts, read, parse and save page content and monitor and act ' & @CR
  2523. $sHTML &= 'upon browser "events".<br>' & @CR
  2524. $sHTML &= 'IE.au3 uses the COM interface in AutoIt to interact with the Internet Explorer ' & @CR
  2525. $sHTML &= 'object model and the DOM (Document Object Model) supported by the browser.' & @CR
  2526. $sHTML &= '<br>' & @CR
  2527. $sHTML &= 'Here are some links for more information and helpful tools:<br>' & @CR
  2528. $sHTML &= 'Reference Material: ' & @CR
  2529. $sHTML &= '<ul>' & @CR
  2530. $sHTML &= '<li><a href="http://msdn1.microsoft.com/">MSDN (Microsoft Developer Network)</a></li>' & @CR
  2531. $sHTML &= '<li><a href="http://msdn2.microsoft.com/en-us/library/aa752084.aspx" target="_blank">InternetExplorer Object</a></li>' & @CR
  2532. $sHTML &= '<li><a href="http://msdn2.microsoft.com/en-us/library/ms531073.aspx" target="_blank">Document Object</a></li>' & @CR
  2533. $sHTML &= '<li><a href="http://msdn2.microsoft.com/en-us/ie/aa740473.aspx" target="_blank">Overviews and Tutorials</a></li>' & @CR
  2534. $sHTML &= '<li><a href="http://msdn2.microsoft.com/en-us/library/ms533029.aspx" target="_blank">DHTML Objects</a></li>' & @CR
  2535. $sHTML &= '<li><a href="http://msdn2.microsoft.com/en-us/library/ms533051.aspx" target="_blank">DHTML Events</a></li>' & @CR
  2536. $sHTML &= '</ul><br>' & @CR
  2537. $sHTML &= 'Helpful Tools: ' & @CR
  2538. $sHTML &= '<ul>' & @CR
  2539. $sHTML &= '<li><a href="http://www.autoitscript.com/forum/index.php?showtopic=19368" target="_blank">AutoIt IE Builder</a> (build IE scripts interactively)</li>' & @CR
  2540. $sHTML &= '<li><a href="http://www.debugbar.com/" target="_blank">DebugBar</a> (DOM inspector, HTTP inspector, HTML validator and more - free for personal use) Recommended</li>' & @CR
  2541. $sHTML &= '<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&amp;displaylang=en" target="_blank">IE Developer Toolbar</a> (comprehensive DOM analysis tool)</li>' & @CR
  2542. $sHTML &= '<li><a href="http://slayeroffice.com/tools/modi/v2.0/modi_help.html" target="_blank">MODIV2</a> (view the DOM of a web page by mousing around)</li>' & @CR
  2543. $sHTML &= '<li><a href="http://validator.w3.org/" target="_blank">HTML Validator</a> (verify HTML follows format rules)</li>' & @CR
  2544. $sHTML &= '<li><a href="http://www.fiddlertool.com/fiddler/" target="_blank">Fiddler</a> (examine HTTP traffic)</li>' & @CR
  2545. $sHTML &= '</ul>' & @CR
  2546. $sHTML &= '</td>' & @CR
  2547. $sHTML &= '</tr>' & @CR
  2548. $sHTML &= '</table>' & @CR
  2549. $sHTML &= '</body>' & @CR
  2550. $sHTML &= '</html>'
  2551. Case Else
  2552. __IEConsoleWriteError("Error", "_IE_Introduction", "$_IESTATUS_InvalidValue")
  2553. Return SetError($_IESTATUS_InvalidValue, 1, 0)
  2554. EndSwitch
  2555. Local $oObject = _IECreate()
  2556. _IEDocWriteHTML($oObject, $sHTML)
  2557. Return SetError($_IESTATUS_Success, 0, $oObject)
  2558. EndFunc ;==>_IE_Introduction
  2559. ; #FUNCTION# ====================================================================================================================
  2560. ; Author ........: Dale Hohm
  2561. ; Modified ......: jpm
  2562. ; ===============================================================================================================================
  2563. Func _IE_Example($sModule = "basic")
  2564. Local $sHTML = "", $oObject
  2565. Switch $sModule
  2566. Case "basic"
  2567. $sHTML &= '<!DOCTYPE html>' & @CR
  2568. $sHTML &= '<html>' & @CR
  2569. $sHTML &= '<head>' & @CR
  2570. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  2571. $sHTML &= '<title>_IE_Example("basic")</title>' & @CR
  2572. $sHTML &= '<style>body {font-family: Arial}</style>' & @CR
  2573. $sHTML &= '</head>' & @CR
  2574. $sHTML &= '<body>' & @CR
  2575. $sHTML &= '<a href="http://www.autoitscript.com"><img src="http://www.autoitscript.com/images/logo_autoit_210x72.png" id="AutoItImage" alt="AutoIt Homepage Image" style="background: #204080;"></a>' & @CR
  2576. $sHTML &= '<p></p>' & @CR
  2577. $sHTML &= '<div id="line1">This is a simple HTML page with text, links and images.</div>' & @CR
  2578. $sHTML &= '<br>' & @CR
  2579. $sHTML &= '<div id="line2"><a href="http://www.autoitscript.com">AutoIt</a> is a wonderful automation scripting language.</div>' & @CR
  2580. $sHTML &= '<br>' & @CR
  2581. $sHTML &= '<div id="line3">It is supported by a very active and supporting <a href="http://www.autoitscript.com/forum/">user forum</a>.</div>' & @CR
  2582. $sHTML &= '<br>' & @CR
  2583. $sHTML &= '<div id="IEAu3Data"></div>' & @CR
  2584. $sHTML &= '</body>' & @CR
  2585. $sHTML &= '</html>'
  2586. $oObject = _IECreate()
  2587. _IEDocWriteHTML($oObject, $sHTML)
  2588. Case "table"
  2589. $sHTML &= '<!DOCTYPE html>' & @CR
  2590. $sHTML &= '<html>' & @CR
  2591. $sHTML &= '<head>' & @CR
  2592. $sHTML &= '<meta content="text/html; charset=utf-8" http-equiv="content-type">' & @CR
  2593. $sHTML &= '<title>_IE_Example("table")</title>' & @CR
  2594. $sHTML &= '<style>body {font-family: Arial}</style>' & @CR
  2595. $sHTML &= '</head>' & @CR
  2596. $sHTML &= '<body>' & @CR
  2597. $sHTML &= '$oTableOne = _IETableGetObjByName($oIE, "tableOne")<br>' & @CR
  2598. $sHTML &= '&lt;table border=1 id="tableOne"&gt;<br>' & @CR
  2599. $sHTML &= '<table border=1 id="tableOne">' & @CR
  2600. $sHTML &= ' <tr>' & @CR
  2601. $sHTML &= ' <td>AutoIt</td>' & @CR
  2602. $sHTML &= ' <td>is</td>' & @CR
  2603. $sHTML &= ' <td>really</td>' & @CR
  2604. $sHTML &= ' <td>great</td>' & @CR
  2605. $sHTML &= ' <td>with</td>' & @CR
  2606. $sHTML &= ' <td>IE.au3</td>' & @CR
  2607. $sHTML &= ' </tr>' & @CR
  2608. $sHTML &= ' <tr>' & @CR
  2609. $sHTML &= ' <td>1</td>' & @CR
  2610. $sHTML &= ' <td>2</td>' & @CR
  2611. $sHTML &= ' <td>3</td>' & @CR
  2612. $sHTML &= ' <td>4</td>' & @CR
  2613. $sHTML &= ' <td>5</td>' & @CR
  2614. $sHTML &= ' <td>6</td>' & @CR
  2615. $sHTML &= ' </tr>' & @CR
  2616. $sHTML &= ' <tr>' & @CR
  2617. $sHTML &= ' <td>the</td>' & @CR
  2618. $sHTML &= ' <td>quick</td>' & @CR
  2619. $sHTML &= ' <td>red</td>' & @CR
  2620. $sHTML &= ' <td>fox</td>' & @CR
  2621. $sHTML &= ' <td>jumped</td>' & @CR
  2622. $sHTML &= ' <td>over</td>' & @CR
  2623. $sHTML &= ' </tr>' & @CR
  2624. $sHTML &= ' <tr>' & @CR
  2625. $sHTML &= ' <td>the</td>' & @CR
  2626. $sHTML &= ' <td>lazy</td>' & @CR
  2627. $sHTML &= ' <td>brown</td>' & @CR
  2628. $sHTML &= ' <td>dog</td>' & @CR
  2629. $sHTML &= ' <td>the</td>' & @CR
  2630. $sHTML &= ' <td>time</td>' & @CR
  2631. $sHTML &= ' </tr>' & @CR
  2632. $sHTML &= ' <tr>' & @CR
  2633. $sHTML &= ' <td>has</td>' & @CR
  2634. $sHTML &= ' <td>come</td>' & @CR
  2635. $sHTML &= ' <td>for</td>' & @CR
  2636. $sHTML &= ' <td>all</td>' & @CR
  2637. $sHTML &= ' <td>good</td>' & @CR
  2638. $sHTML &= ' <td>men</td>' & @CR
  2639. $sHTML &= ' </tr>' & @CR
  2640. $sHTML &= ' <tr>' & @CR
  2641. $sHTML &= ' <td>to</td>' & @CR
  2642. $sHTML &= ' <td>come</td>' & @CR
  2643. $sHTML &= ' <td>to</td>' & @CR
  2644. $sHTML &= ' <td>the</td>' & @CR
  2645. $sHTML &= ' <td>aid</td>' & @CR
  2646. $sHTML &= ' <td>of</td>' & @CR
  2647. $sHTML &= ' </tr>' & @CR
  2648. $sHTML &= '</table>' & @CR
  2649. $sHTML &= '<br>' & @CR
  2650. $sHTML &= '$oTableTwo = _IETableGetObjByName($oIE, "tableTwo")<br>' & @CR
  2651. $sHTML &= '&lt;table border="1" id="tableTwo"&gt;<br>' & @CR
  2652. $sHTML &= '<table border=1 id="tableTwo">' & @CR
  2653. $sHTML &= ' <tr>' & @CR
  2654. $sHTML &= ' <td colspan="4">Table Top</td>' & @CR
  2655. $sHTML &= ' </tr>' & @CR
  2656. $sHTML &= ' <tr>' & @CR
  2657. $sHTML &= ' <td>One</td>' & @CR
  2658. $sHTML &= ' <td colspan="3">Two</td>' & @CR
  2659. $sHTML &= ' </tr>' & @CR
  2660. $sHTML &= ' <tr>' & @CR
  2661. $sHTML &= ' <td>Three</td>' & @CR
  2662. $sHTML &= ' <td>Four</td>' & @CR
  2663. $sHTML &= ' <td colspan="2">Five</td>' & @CR
  2664. $sHTML &= ' </tr>' & @CR
  2665. $sHTML &= ' <tr>' & @CR
  2666. $sHTML &= ' <td>Six</td>' & @CR
  2667. $sHTML &= ' <td colspan="3">Seven</td>' & @CR
  2668. $sHTML &= ' </tr>' & @CR
  2669. $sHTML &= ' <tr>' & @CR
  2670. $sHTML &= ' <td>Eight</td>' & @CR
  2671. $sHTML &= ' <td>Nine</td>' & @CR
  2672. $sHTML &= ' <td>Ten</td>' & @CR
  2673. $sHTML &= ' <td>Eleven</td>' & @CR
  2674. $sHTML &= ' </tr>' & @CR
  2675. $sHTML &= '</table>' & @CR
  2676. $sHTML &= '</body>' & @CR
  2677. $sHTML &= '</html>'
  2678. $oObject = _IECreate()
  2679. _IEDocWriteHTML($oObject, $sHTML)
  2680. Case "form"
  2681. $sHTML &= '<!DOCTYPE html>' & @CR
  2682. $sHTML &= '<html>' & @CR
  2683. $sHTML &= '<head>' & @CR
  2684. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  2685. $sHTML &= '<title>_IE_Example("form")</title>' & @CR
  2686. $sHTML &= '<style>body {font-family: Arial}' & @CR
  2687. $sHTML &= 'td {padding:6px}</style>' & @CR
  2688. $sHTML &= '</head>' & @CR
  2689. $sHTML &= '<body>' & @CR
  2690. $sHTML &= '<form name="ExampleForm" onSubmit="javascript:alert(''ExampleFormSubmitted'');" method="post">' & @CR
  2691. $sHTML &= '<table style="border-spacing:6px 6px;" border=1>' & @CR
  2692. $sHTML &= '<tr>' & @CR
  2693. $sHTML &= '<td>ExampleForm</td>' & @CR
  2694. $sHTML &= '<td>&lt;form name="ExampleForm" onSubmit="javascript:alert(''ExampleFormSubmitted'');" method="post"&gt;</td>' & @CR
  2695. $sHTML &= '</tr>' & @CR
  2696. $sHTML &= '<tr>' & @CR
  2697. $sHTML &= '<td>Hidden Input Element<input type="hidden" name="hiddenExample" value="secret value"></td>' & @CR
  2698. $sHTML &= '<td>&lt;input type="hidden" name="hiddenExample" value="secret value"&gt;</td>' & @CR
  2699. $sHTML &= '</tr>' & @CR
  2700. $sHTML &= '<tr>' & @CR
  2701. $sHTML &= '<td>' & @CR
  2702. $sHTML &= '<input type="text" name="textExample" value="http://" size="20" maxlength="30">' & @CR
  2703. $sHTML &= '</td>' & @CR
  2704. $sHTML &= '<td>&lt;input type="text" name="textExample" value="http://" size="20" maxlength="30"&gt;</td>' & @CR
  2705. $sHTML &= '</tr>' & @CR
  2706. $sHTML &= '<tr>' & @CR
  2707. $sHTML &= '<td>' & @CR
  2708. $sHTML &= '<input type="password" name="passwordExample" size="10">' & @CR
  2709. $sHTML &= '</td>' & @CR
  2710. $sHTML &= '<td>&lt;input type="password" name="passwordExample" size="10"&gt;</td>' & @CR
  2711. $sHTML &= '</tr>' & @CR
  2712. $sHTML &= '<tr>' & @CR
  2713. $sHTML &= '<td>' & @CR
  2714. $sHTML &= '<input type="file" name="fileExample">' & @CR
  2715. $sHTML &= '</td>' & @CR
  2716. $sHTML &= '<td>&lt;input type="file" name="fileExample"&gt;</td>' & @CR
  2717. $sHTML &= '</tr>' & @CR
  2718. $sHTML &= '<tr>' & @CR
  2719. $sHTML &= '<td>' & @CR
  2720. $sHTML &= '<input type="image" name="imageExample" alt="AutoIt Homepage" src="http://www.autoitscript.com/images/logo_autoit_210x72.png" style="background: #204080;>' & @CR
  2721. $sHTML &= '</td>' & @CR
  2722. $sHTML &= '<td>&lt;input type="image" name="imageExample" alt="AutoIt Homepage" src="http://www.autoitscript.com/images/logo_autoit_210x72.png"&gt;</td>' & @CR
  2723. $sHTML &= '</tr>' & @CR
  2724. $sHTML &= '<tr>' & @CR
  2725. $sHTML &= '<td>' & @CR
  2726. $sHTML &= '<textarea name="textareaExample" rows="5" cols="15">Hello!</textarea>' & @CR
  2727. $sHTML &= '</td>' & @CR
  2728. $sHTML &= '<td>&lt;textarea name="textareaExample" rows="5" cols="15"&gt;Hello!&lt;/textarea&gt;</td>' & @CR
  2729. $sHTML &= '</tr>' & @CR
  2730. $sHTML &= '<tr>' & @CR
  2731. $sHTML &= '<td>' & @CR
  2732. $sHTML &= '<input type="checkbox" name="checkboxG1Example" value="gameBasketball">Basketball<br>' & @CR
  2733. $sHTML &= '<input type="checkbox" name="checkboxG1Example" value="gameFootball">Football<br>' & @CR
  2734. $sHTML &= '<input type="checkbox" name="checkboxG2Example" value="gameTennis" checked>Tennis<br>' & @CR
  2735. $sHTML &= '<input type="checkbox" name="checkboxG2Example" value="gameBaseball">Baseball' & @CR
  2736. $sHTML &= '</td>' & @CR
  2737. $sHTML &= '<td>&lt;input type="checkbox" name="checkboxG1Example" value="gameBasketball"&gt;Basketball&lt;br&gt;<br>' & @CR
  2738. $sHTML &= '&lt;input type="checkbox" name="checkboxG1Example" value="gameFootball"&gt;Football&lt;br&gt;<br>' & @CR
  2739. $sHTML &= '&lt;input type="checkbox" name="checkboxG2Example" value="gameTennis" checked&gt;Tennis&lt;br&gt;<br>' & @CR
  2740. $sHTML &= '&lt;input type="checkbox" name="checkboxG2Example" value="gameBaseball"&gt;Baseball</td>' & @CR
  2741. $sHTML &= '</tr>' & @CR
  2742. $sHTML &= '<tr>' & @CR
  2743. $sHTML &= '<td>' & @CR
  2744. $sHTML &= '<input type="radio" name="radioExample" value="vehicleAirplane">Airplane<br>' & @CR
  2745. $sHTML &= '<input type="radio" name="radioExample" value="vehicleTrain" checked>Train<br>' & @CR
  2746. $sHTML &= '<input type="radio" name="radioExample" value="vehicleBoat">Boat<br>' & @CR
  2747. $sHTML &= '<input type="radio" name="radioExample" value="vehicleCar">Car</td>' & @CR
  2748. $sHTML &= '<td>&lt;input type="radio" name="radioExample" value="vehicleAirplane"&gt;Airplane&lt;br&gt;<br>' & @CR
  2749. $sHTML &= '&lt;input type="radio" name="radioExample" value="vehicleTrain" checked&gt;Train&lt;br&gt;<br>' & @CR
  2750. $sHTML &= '&lt;input type="radio" name="radioExample" value="vehicleBoat"&gt;Boat&lt;br&gt;<br>' & @CR
  2751. $sHTML &= '&lt;input type="radio" name="radioExample" value="vehicleCar"&gt;Car&lt;br&gt;</td>' & @CR
  2752. $sHTML &= '</tr>' & @CR
  2753. $sHTML &= '<tr>' & @CR
  2754. $sHTML &= '<td>' & @CR
  2755. $sHTML &= '<select name="selectExample">' & @CR
  2756. $sHTML &= '<option value="homepage.html">Homepage' & @CR
  2757. $sHTML &= '<option value="midipage.html">Midipage' & @CR
  2758. $sHTML &= '<option value="freepage.html">Freepage' & @CR
  2759. $sHTML &= '</select>' & @CR
  2760. $sHTML &= '</td>' & @CR
  2761. $sHTML &= '<td>&lt;select name="selectExample"&gt;<br>' & @CR
  2762. $sHTML &= '&lt;option value="homepage.html"&gt;Homepage<br>' & @CR
  2763. $sHTML &= '&lt;option value="midipage.html"&gt;Midipage<br>' & @CR
  2764. $sHTML &= '&lt;option value="freepage.html"&gt;Freepage<br>' & @CR
  2765. $sHTML &= '&lt;/select&gt;</td>' & @CR
  2766. $sHTML &= '</tr>' & @CR
  2767. $sHTML &= '<tr>' & @CR
  2768. $sHTML &= '<td>' & @CR
  2769. $sHTML &= '<select name="multipleSelectExample" size="6" multiple>' & @CR
  2770. $sHTML &= '<option value="Name1">Aaron' & @CR
  2771. $sHTML &= '<option value="Name2">Bruce' & @CR
  2772. $sHTML &= '<option value="Name3">Carlos' & @CR
  2773. $sHTML &= '<option value="Name4">Denis' & @CR
  2774. $sHTML &= '<option value="Name5">Ed' & @CR
  2775. $sHTML &= '<option value="Name6">Freddy' & @CR
  2776. $sHTML &= '</select>' & @CR
  2777. $sHTML &= '</td>' & @CR
  2778. $sHTML &= '<td>&lt;select name="multipleSelectExample" size="6" multiple&gt;<br>' & @CR
  2779. $sHTML &= '&lt;option value="Name1"&gt;Aaron<br>' & @CR
  2780. $sHTML &= '&lt;option value="Name2"&gt;Bruce<br>' & @CR
  2781. $sHTML &= '&lt;option value="Name3"&gt;Carlos<br>' & @CR
  2782. $sHTML &= '&lt;option value="Name4"&gt;Denis<br>' & @CR
  2783. $sHTML &= '&lt;option value="Name5"&gt;Ed<br>' & @CR
  2784. $sHTML &= '&lt;option value="Name6"&gt;Freddy<br>' & @CR
  2785. $sHTML &= '&lt;/select&gt;</td>' & @CR
  2786. $sHTML &= '</tr>' & @CR
  2787. $sHTML &= '<tr>' & @CR
  2788. $sHTML &= '<td>' & @CR
  2789. $sHTML &= '<input name="submitExample" type="submit" value="Submit">' & @CR
  2790. $sHTML &= '<input name="resetExample" type="reset" value="Reset">' & @CR
  2791. $sHTML &= '</td>' & @CR
  2792. $sHTML &= '<td>&lt;input name="submitExample" type="submit" value="Submit"&gt;<br>' & @CR
  2793. $sHTML &= '&lt;input name="resetExample" type="reset" value="Reset"&gt;</td>' & @CR
  2794. $sHTML &= '</tr>' & @CR
  2795. $sHTML &= '</table>' & @CR
  2796. $sHTML &= '<input type="hidden" name="hiddenExample" value="secret value">' & @CR
  2797. $sHTML &= '</form>' & @CR
  2798. $sHTML &= '</body>' & @CR
  2799. $sHTML &= '</html>'
  2800. $oObject = _IECreate()
  2801. _IEDocWriteHTML($oObject, $sHTML)
  2802. Case "frameset"
  2803. $sHTML &= '<!DOCTYPE html>' & @CR
  2804. $sHTML &= '<html>' & @CR
  2805. $sHTML &= '<head>' & @CR
  2806. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  2807. $sHTML &= '<title>_IE_Example("frameset")</title>' & @CR
  2808. $sHTML &= '</head>' & @CR
  2809. $sHTML &= '<frameset rows="25,200">' & @CR
  2810. $sHTML &= ' <frame name=Top SRC=about:blank>' & @CR
  2811. $sHTML &= ' <frameset cols="100,500">' & @CR
  2812. $sHTML &= ' <frame name=Menu SRC=about:blank>' & @CR
  2813. $sHTML &= ' <frame name=Main SRC=about:blank>' & @CR
  2814. $sHTML &= ' </frameset>' & @CR
  2815. $sHTML &= '</frameset>' & @CR
  2816. $sHTML &= '</html>'
  2817. $oObject = _IECreate()
  2818. _IEDocWriteHTML($oObject, $sHTML)
  2819. _IEAction($oObject, "refresh")
  2820. Local $oFrameTop = _IEFrameGetObjByName($oObject, "Top")
  2821. Local $oFrameMenu = _IEFrameGetObjByName($oObject, "Menu")
  2822. Local $oFrameMain = _IEFrameGetObjByName($oObject, "Main")
  2823. _IEBodyWriteHTML($oFrameTop, '$oFrameTop = _IEFrameGetObjByName($oIE, "Top")')
  2824. _IEBodyWriteHTML($oFrameMenu, '$oFrameMenu = _IEFrameGetObjByName($oIE, "Menu")')
  2825. _IEBodyWriteHTML($oFrameMain, '$oFrameMain = _IEFrameGetObjByName($oIE, "Main")')
  2826. Case "iframe"
  2827. $sHTML &= '<!DOCTYPE html>' & @CR
  2828. $sHTML &= '<html>' & @CR
  2829. $sHTML &= '<head>' & @CR
  2830. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  2831. $sHTML &= '<title>_IE_Example("iframe")</title>' & @CR
  2832. $sHTML &= '<style>td {padding:6px}</style>' & @CR
  2833. $sHTML &= '</head>' & @CR
  2834. $sHTML &= '<body>' & @CR
  2835. $sHTML &= '<table style="border-spacing:6px" border=1>' & @CR
  2836. $sHTML &= '<tr>' & @CR
  2837. $sHTML &= '<td><iframe name="iFrameOne" src="about:blank" title="iFrameOne"></iframe></td>' & @CR
  2838. $sHTML &= '<td>&lt;iframe name="iFrameOne" src="about:blank" title="iFrameOne"&gt;</td>' & @CR
  2839. $sHTML &= '</tr>' & @CR
  2840. $sHTML &= '<tr>' & @CR
  2841. $sHTML &= '<td><iframe name="iFrameTwo" src="about:blank" title="iFrameTwo"></iframe></td>' & @CR
  2842. $sHTML &= '<td>&lt;iframe name="iFrameTwo" src="about:blank" title="iFrameTwo"&gt;</td>' & @CR
  2843. $sHTML &= '</tr>' & @CR
  2844. $sHTML &= '</table>' & @CR
  2845. $sHTML &= '</body>' & @CR
  2846. $sHTML &= '</html>'
  2847. $oObject = _IECreate()
  2848. _IEDocWriteHTML($oObject, $sHTML)
  2849. _IEAction($oObject, "refresh")
  2850. Local $oIFrameOne = _IEFrameGetObjByName($oObject, "iFrameOne")
  2851. Local $oIFrameTwo = _IEFrameGetObjByName($oObject, "iFrameTwo")
  2852. _IEBodyWriteHTML($oIFrameOne, '$oIFrameOne = _IEFrameGetObjByName($oIE, "iFrameOne")')
  2853. _IEBodyWriteHTML($oIFrameTwo, '$oIFrameTwo = _IEFrameGetObjByName($oIE, "iFrameTwo")')
  2854. Case Else
  2855. __IEConsoleWriteError("Error", "_IE_Example", "$_IESTATUS_InvalidValue")
  2856. Return SetError($_IESTATUS_InvalidValue, 1, 0)
  2857. EndSwitch
  2858. ; at least under IE10 some delay is needed to have functions as _IEPropertySet() working
  2859. ; value can depend of processor speed ...
  2860. Sleep(500)
  2861. Return SetError($_IESTATUS_Success, 0, $oObject)
  2862. EndFunc ;==>_IE_Example
  2863. ; #FUNCTION# ====================================================================================================================
  2864. ; Author ........: Dale Hohm
  2865. ; ===============================================================================================================================
  2866. Func _IE_VersionInfo()
  2867. __IEConsoleWriteError("Information", "_IE_VersionInfo", "version " & _
  2868. $__gaIEAU3VersionInfo[0] & _
  2869. $__gaIEAU3VersionInfo[1] & "." & _
  2870. $__gaIEAU3VersionInfo[2] & "-" & _
  2871. $__gaIEAU3VersionInfo[3], "Release date: " & $__gaIEAU3VersionInfo[4])
  2872. Return SetError($_IESTATUS_Success, 0, $__gaIEAU3VersionInfo)
  2873. EndFunc ;==>_IE_VersionInfo
  2874. #EndRegion General
  2875. #Region Internal functions
  2876. ;
  2877. ; Internal Functions with names starting with two underscores will not be documented
  2878. ; as user functions
  2879. ;
  2880. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2881. ; Name...........: __IELockSetForegroundWindow
  2882. ; Description ...: Locks (and Unlocks) current Foregrouns Window focus to prevent a new window
  2883. ; from stealing it (e.g. when creating invisible IE browser)
  2884. ; Parameters ....: $iLockCode - 1 Lock Foreground Window Focus, 2 Unlock Foreground Window Focus
  2885. ; Return values .: On Success - 1
  2886. ; On Failure - 0 and sets @error and @extended to non-zero values
  2887. ; Author ........: Valik
  2888. ; ===============================================================================================================================
  2889. Func __IELockSetForegroundWindow($iLockCode)
  2890. Local $aRet = DllCall("user32.dll", "bool", "LockSetForegroundWindow", "uint", $iLockCode)
  2891. If @error Or Not $aRet[0] Then Return SetError(1, _WinAPI_GetLastError(), 0)
  2892. Return $aRet[0]
  2893. EndFunc ;==>__IELockSetForegroundWindow
  2894. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2895. ; Name...........: __IEControlGetObjFromHWND
  2896. ; Description ...: Returns a COM Object Window reference to an embebedded Webbrowser control
  2897. ; Parameters ....: $hWin - HWND of a Internet Explorer_Server1 control obtained for example:
  2898. ; $hwnd = ControlGetHandle("MyApp","","Internet Explorer_Server1")
  2899. ; Return values .: On Success - Returns DOM Window object
  2900. ; On Failure - 0 and sets @error = 1
  2901. ; Author ........: Larry with thanks to Valik
  2902. ; Remarks .......:
  2903. ; ===============================================================================================================================
  2904. Func __IEControlGetObjFromHWND(ByRef $hWin)
  2905. ; The code assumes CoInitialize() succeeded due to the number of different
  2906. ; yet successful return values it has.
  2907. DllCall("ole32.dll", "long", "CoInitialize", "ptr", 0)
  2908. If @error Then Return SetError(2, @error, 0)
  2909. Local Const $WM_HTML_GETOBJECT = __IERegisterWindowMessage("WM_HTML_GETOBJECT")
  2910. Local Const $SMTO_ABORTIFHUNG = 0x0002
  2911. Local $iResult
  2912. __IESendMessageTimeout($hWin, $WM_HTML_GETOBJECT, 0, 0, $SMTO_ABORTIFHUNG, 1000, $iResult)
  2913. Local $tUUID = DllStructCreate("int;short;short;byte[8]")
  2914. DllStructSetData($tUUID, 1, 0x626FC520)
  2915. DllStructSetData($tUUID, 2, 0xA41E)
  2916. DllStructSetData($tUUID, 3, 0x11CF)
  2917. DllStructSetData($tUUID, 4, 0xA7, 1)
  2918. DllStructSetData($tUUID, 4, 0x31, 2)
  2919. DllStructSetData($tUUID, 4, 0x0, 3)
  2920. DllStructSetData($tUUID, 4, 0xA0, 4)
  2921. DllStructSetData($tUUID, 4, 0xC9, 5)
  2922. DllStructSetData($tUUID, 4, 0x8, 6)
  2923. DllStructSetData($tUUID, 4, 0x26, 7)
  2924. DllStructSetData($tUUID, 4, 0x37, 8)
  2925. Local $aRet = DllCall("oleacc.dll", "long", "ObjectFromLresult", "lresult", $iResult, "struct*", $tUUID, _
  2926. "wparam", 0, "idispatch*", 0)
  2927. If @error Then Return SetError(3, @error, 0)
  2928. If IsObj($aRet[4]) Then
  2929. Local $oIE = $aRet[4].Script()
  2930. ; $oIE is now a valid IDispatch object
  2931. Return $oIE.Document.parentwindow
  2932. Else
  2933. Return SetError(1, $aRet[0], 0)
  2934. EndIf
  2935. EndFunc ;==>__IEControlGetObjFromHWND
  2936. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2937. ; Name...........: __IERegisterWindowMessage
  2938. ; Description ...: Required by __IEControlGetObjFromHWND()
  2939. ; Author ........: Larry with thanks to Valik
  2940. ; ===============================================================================================================================
  2941. Func __IERegisterWindowMessage($sMsg)
  2942. Local $aRet = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $sMsg)
  2943. If @error Then Return SetError(@error, @extended, 0)
  2944. If $aRet[0] = 0 Then Return SetError(10, _WinAPI_GetLastError(), 0)
  2945. Return $aRet[0]
  2946. EndFunc ;==>__IERegisterWindowMessage
  2947. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2948. ; Name...........: __IESendMessageTimeout
  2949. ; Description ...: Required by __IEControlGetObjFromHWND()
  2950. ; Author ........: Larry with thanks to Valik
  2951. ; ===============================================================================================================================
  2952. Func __IESendMessageTimeout($hWnd, $iMsg, $wParam, $lParam, $iFlags, $iTimeout, ByRef $vOut, $r = 0, $sT1 = "int", $sT2 = "int")
  2953. Local $aRet = DllCall("user32.dll", "lresult", "SendMessageTimeout", "hwnd", $hWnd, "uint", $iMsg, $sT1, $wParam, _
  2954. $sT2, $lParam, "uint", $iFlags, "uint", $iTimeout, "dword_ptr*", "")
  2955. If @error Or $aRet[0] = 0 Then
  2956. $vOut = 0
  2957. Return SetError(1, _WinAPI_GetLastError(), 0)
  2958. EndIf
  2959. $vOut = $aRet[7]
  2960. If $r >= 0 And $r <= 4 Then Return $aRet[$r]
  2961. Return $aRet
  2962. EndFunc ;==>__IESendMessageTimeout
  2963. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2964. ; Name...........: __IEIsObjType
  2965. ; Description ...: Check to see if an object variable is of a specific type
  2966. ; Author ........: Dale Hohm
  2967. ; Modified ......: jpm
  2968. ; ===============================================================================================================================
  2969. Func __IEIsObjType(ByRef $oObject, $sType, $bRegister = True)
  2970. If Not IsObj($oObject) Then
  2971. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  2972. EndIf
  2973. ; Setup internal error handler to Trap COM errors, turn off error notification
  2974. Local $bStatus = $bRegister
  2975. If $bRegister Then
  2976. $bStatus = __IEInternalErrorHandlerRegister()
  2977. If Not $bStatus Then __IEConsoleWriteError("Warning", "internal function __IEIsObjType", _
  2978. "Cannot register internal error handler, cannot trap COM errors", _
  2979. "Use _IEErrorHandlerRegister() to register a user error handler")
  2980. EndIf
  2981. Local $iNotifyStatus = _IEErrorNotify() ; save current error notify status
  2982. _IEErrorNotify(False)
  2983. ;
  2984. Local $sName = String(ObjName($oObject)), $iErrorStatus = $_IESTATUS_InvalidObjectType
  2985. Switch $sType
  2986. Case "browserdom"
  2987. If __IEIsObjType($oObject, "documentcontainer", False) Then
  2988. $iErrorStatus = $_IESTATUS_Success
  2989. ElseIf __IEIsObjType($oObject, "document", False) Then
  2990. $iErrorStatus = $_IESTATUS_Success
  2991. Else
  2992. Local $oTemp = $oObject.document
  2993. If __IEIsObjType($oTemp, "document", False) Then
  2994. $iErrorStatus = $_IESTATUS_Success
  2995. EndIf
  2996. EndIf
  2997. Case "browser"
  2998. If ($sName = "IWebBrowser2") Or ($sName = "IWebBrowser") Or ($sName = "WebBrowser") Then $iErrorStatus = $_IESTATUS_Success
  2999. Case "window"
  3000. If $sName = "HTMLWindow2" Then $iErrorStatus = $_IESTATUS_Success
  3001. Case "documentContainer"
  3002. If __IEIsObjType($oObject, "window", False) Or __IEIsObjType($oObject, "browser", False) Then $iErrorStatus = $_IESTATUS_Success
  3003. Case "document"
  3004. If $sName = "HTMLDocument" Then $iErrorStatus = $_IESTATUS_Success
  3005. Case "table"
  3006. If $sName = "HTMLTable" Then $iErrorStatus = $_IESTATUS_Success
  3007. Case "form"
  3008. If $sName = "HTMLFormElement" Then $iErrorStatus = $_IESTATUS_Success
  3009. Case "forminputelement"
  3010. If ($sName = "HTMLInputElement") Or ($sName = "HTMLSelectElement") Or ($sName = "HTMLTextAreaElement") Then $iErrorStatus = $_IESTATUS_Success
  3011. Case "elementcollection"
  3012. If ($sName = "HTMLElementCollection") Then $iErrorStatus = $_IESTATUS_Success
  3013. Case "formselectelement"
  3014. If $sName = "HTMLSelectElement" Then $iErrorStatus = $_IESTATUS_Success
  3015. Case Else
  3016. ; Unsupported ObjType specified
  3017. $iErrorStatus = $_IESTATUS_InvalidValue
  3018. EndSwitch
  3019. ; restore error notify
  3020. _IEErrorNotify($iNotifyStatus) ; restore notification status
  3021. If $bRegister Then
  3022. __IEInternalErrorHandlerDeRegister()
  3023. EndIf
  3024. If $iErrorStatus = $_IESTATUS_Success Then
  3025. Return SetError($_IESTATUS_Success, 0, 1)
  3026. Else
  3027. Return SetError($iErrorStatus, 1, 0)
  3028. EndIf
  3029. EndFunc ;==>__IEIsObjType
  3030. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3031. ; Name...........: __IEConsoleWriteError
  3032. ; Description ...: ConsoleWrite an error message if required
  3033. ; Author ........: Dale Hohm
  3034. ; Modified ......: jpm
  3035. ; ===============================================================================================================================
  3036. Func __IEConsoleWriteError($sSeverity, $sFunc, $sMessage = Default, $sStatus = Default)
  3037. If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then
  3038. Local $sStr = "--> IE.au3 " & $__gaIEAU3VersionInfo[5] & " " & $sSeverity & " from function " & $sFunc
  3039. If Not ($sMessage = Default) Then $sStr &= ", " & $sMessage
  3040. If Not ($sStatus = Default) Then $sStr &= " (" & $sStatus & ")"
  3041. ConsoleWrite($sStr & @CRLF)
  3042. EndIf
  3043. Return SetError($sStatus, 0, 1) ; restore calling @error
  3044. EndFunc ;==>__IEConsoleWriteError
  3045. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3046. ; Name...........: __IEComErrorUnrecoverable
  3047. ; Description ...: Internal function to test a COM error condition and determine if it is considered unrecoverable
  3048. ; Parameters ....: Error number
  3049. ; Return values .: Unrecoverable: True, Else: False
  3050. ; Author ........: Dale Hohm
  3051. ; Modified ......: jpm
  3052. ; ===============================================================================================================================
  3053. Func __IEComErrorUnrecoverable($iError)
  3054. Switch $iError
  3055. ; Cross-domain scripting security error
  3056. Case -2147352567 ; "an exception has occurred."
  3057. Return $_IESTATUS_AccessIsDenied
  3058. Case -2147024891 ; "Access is denied."
  3059. Return $_IESTATUS_AccessIsDenied
  3060. ;
  3061. ; Browser object is destroyed before we try to operate upon it
  3062. Case -2147417848 ; "The object invoked has disconnected from its clients."
  3063. Return $_IESTATUS_ClientDisconnected
  3064. Case -2147023174 ; "RPC server not accessible."
  3065. Return $_IESTATUS_ClientDisconnected
  3066. Case -2147023179 ; "The interface is unknown."
  3067. Return $_IESTATUS_ClientDisconnected
  3068. ;
  3069. Case Else
  3070. Return $_IESTATUS_Success
  3071. EndSwitch
  3072. EndFunc ;==>__IEComErrorUnrecoverable
  3073. #EndRegion Internal functions
  3074. #Region ProtoType Functions
  3075. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3076. ; Name...........: __IENavigate
  3077. ; Description ...: ** Unsupported version of _IENavigate (note second underscore in function name)
  3078. ; ** Last 4 parameters insufficiently tested.
  3079. ; ** - Flags and Target can create new windows and new browser object - causing confusion
  3080. ; ** - Postdata needs SAFEARRAY and we have no way to create one
  3081. ; Directs an existing browser window to navigate to the specified URL
  3082. ; Parameters ....: $oObject - Object variable of an InternetExplorer.Application, Window or Frame object
  3083. ; $sUrl - URL to navigate to (e.g. "http://www.autoitscript.com")
  3084. ; $iWait - Optional: specifies whether to wait for page to load before returning
  3085. ; 0 = Return immediately, not waiting for page to load
  3086. ; 1 = (Default) Wait for page load to complete before returning
  3087. ; $iFags - URL to navigate to (e.g. "http://www.autoitscript.com")
  3088. ; $sTarget - target frame
  3089. ; $spostdata - data for form method="POST", non-functional - requires safearray
  3090. ; $sHeaders - additional headers to be passed
  3091. ; Return values .: On Success - Returns -1
  3092. ; On Failure - Returns 0 and sets @error
  3093. ; @error - 1 ($_IESTATUS_GeneralError) = General Error
  3094. ; - 3 ($_IESTATUS_InvalidDataType) = Invalid Data Type
  3095. ; - 4 ($_IESTATUS_InvalidObjectType) = Invalid Object Type
  3096. ; - 6 ($_IESTATUS_LoadWaitTimeout) = Load Wait Timeout
  3097. ; - 8 ($_IESTATUS_AccessIsDenied) = Access Is Denied
  3098. ; - 9 ($_IESTATUS_ClientDisconnected) = Client Disconnected
  3099. ; @extended - Contains invalid parameter number
  3100. ; Author ........: Dale Hohm
  3101. ; Remarks .......: AutoIt3 V3.2 or higher, flags for Tabs require IE7 or higher
  3102. ; Additional information on the navigate2 method here: http://msdn.microsoft.com/en-us/library/aa752134.aspx
  3103. ;
  3104. ; Flags:
  3105. ; navOpenInNewWindow = 0x1,
  3106. ; navNoHistory = 0x2,
  3107. ; navNoReadFromCache = 0x4,
  3108. ; navNoWriteToCache = 0x8,
  3109. ; navAllowAutosearch = 0x10,
  3110. ; navBrowserBar = 0x20,
  3111. ; navHyperlink = 0x40,
  3112. ; navEnforceRestricted = 0x80,
  3113. ; navNewWindowsManaged = 0x0100,
  3114. ; navUntrustedForDownload = 0x0200,
  3115. ; navTrustedForActiveX = 0x0400,
  3116. ; navOpenInNewTab = 0x0800,
  3117. ; navOpenInBackgroundTab = 0x1000,
  3118. ; navKeepWordWheelText = 0x2000
  3119. ;
  3120. ; Additional documentation on the flags can be found here:
  3121. ; http://msdn.microsoft.com/en-us/library/aa768360.aspx
  3122. ; ===============================================================================================================================
  3123. Func __IENavigate(ByRef $oObject, $sUrl, $iWait = 1, $iFags = 0, $sTarget = "", $sPostdata = "", $sHeaders = "")
  3124. __IEConsoleWriteError("Warning", "__IENavigate", "Unsupported function called. Not fully tested.")
  3125. If Not IsObj($oObject) Then
  3126. __IEConsoleWriteError("Error", "__IENavigate", "$_IESTATUS_InvalidDataType")
  3127. Return SetError($_IESTATUS_InvalidDataType, 1, 0)
  3128. EndIf
  3129. ;
  3130. If Not __IEIsObjType($oObject, "documentContainer") Then
  3131. __IEConsoleWriteError("Error", "__IENavigate", "$_IESTATUS_InvalidObjectType")
  3132. Return SetError($_IESTATUS_InvalidObjectType, 1, 0)
  3133. EndIf
  3134. ;
  3135. $oObject.navigate($sUrl, $iFags, $sTarget, $sPostdata, $sHeaders)
  3136. If $iWait Then
  3137. _IELoadWait($oObject)
  3138. Return SetError(@error, 0, $oObject)
  3139. EndIf
  3140. Return SetError($_IESTATUS_Success, 0, $oObject)
  3141. EndFunc ;==>__IENavigate
  3142. #cs
  3143. #include <IE.au3>
  3144. ; Simulates the submission of the form from the page:
  3145. ;
  3146. ; http://www.autoitscript.com/forum/index.php?act=Search
  3147. ;
  3148. ; searches for the string safearray and returns the results as posts
  3149. $sFormAction = "http://www.autoitscript.com/forum/index.php?act=Search&CODE=01"
  3150. $sHeader = "Content-Type: application/x-www-form-urlencoded"
  3151. $sDataToPost = "keywords=safearray&namesearch=&forums%5B%5D=all&searchsubs=1&prune=0&prune_type=newer&sort_key=last_post&sort_order=desc&search_in=posts&result_type=posts"
  3152. $oDataToPostBstr = __IEStringToBstr($sDataToPost) ; convert string to BSTR
  3153. ConsoleWrite(__IEBstrToString($oDataToPostBstr) & @CRLF) ; prove we can convert it back to a string
  3154. $oIE = _IECreate()
  3155. $oIE.Navigate( $sFormAction, Default, Default, $oDataToPostBstr, $sHeader)
  3156. ; or
  3157. ;__IENavigate($oIE, $sFormAction, 1, 0, "", $oDataToPostBstr, $sHeader)
  3158. #ce
  3159. Func __IEStringToBstr($sString, $sCharSet = "us-ascii")
  3160. Local Const $iTypeBinary = 1, $iTypeText = 2
  3161. Local $oStream = ObjCreate("ADODB.Stream")
  3162. $oStream.type = $iTypeText
  3163. $oStream.CharSet = $sCharSet
  3164. $oStream.Open
  3165. $oStream.WriteText($sString)
  3166. $oStream.Position = 0
  3167. $oStream.type = $iTypeBinary
  3168. $oStream.Position = 0
  3169. Return $oStream.Read()
  3170. EndFunc ;==>__IEStringToBstr
  3171. Func __IEBstrToString($oBstr, $sCharSet = "us-ascii")
  3172. Local Const $iTypeBinary = 1, $iTypeText = 2
  3173. Local $oStream = ObjCreate("ADODB.Stream")
  3174. $oStream.type = $iTypeBinary
  3175. $oStream.Open
  3176. $oStream.Write($oBstr)
  3177. $oStream.Position = 0
  3178. $oStream.type = $iTypeText
  3179. $oStream.CharSet = $sCharSet
  3180. $oStream.Position = 0
  3181. Return $oStream.ReadText()
  3182. EndFunc ;==>__IEBstrToString
  3183. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3184. ; Name...........: __IECreateNewIE
  3185. ; Description ...: Create a Webbrowser in a seperate process
  3186. ; Parameters ....: None
  3187. ; Return values .: On Success - Returns a Webbrowser object reference
  3188. ; On Failure - Returns 0 and sets @error
  3189. ; @error - 0 ($_IESTATUS_Success) = No Error
  3190. ; - 1 ($_IESTATUS_GeneralError) = General Error
  3191. ; Author ........: Dale Hohm
  3192. ; Modified ......: jpm
  3193. ; Remarks .......: http://msdn2.microsoft.com/en-us/library/ms536471(vs.85).aspx
  3194. ; ===============================================================================================================================
  3195. Func __IECreateNewIE($sTitle, $sHead = "", $sBody = "")
  3196. Local $sTemp = __IETempFile("", "~IE~", ".htm")
  3197. If @error Then
  3198. __IEConsoleWriteError("Error", "_IECreateHTA", "", "Error creating temporary file in @TempDir or @ScriptDir")
  3199. Return SetError($_IESTATUS_GeneralError, 1, 0)
  3200. EndIf
  3201. Local $sHTML = ''
  3202. $sHTML &= '<!DOCTYPE html>' & @CR
  3203. $sHTML &= '<html>' & @CR
  3204. $sHTML &= '<head>' & @CR
  3205. $sHTML &= '<meta content="text/html; charset=UTF-8" http-equiv="content-type">' & @CR
  3206. $sHTML &= '<title>' & $sTemp & '</title>' & @CR & $sHead & @CR
  3207. $sHTML &= '</head>' & @CR
  3208. $sHTML &= '<body>' & @CR & $sBody & @CR
  3209. $sHTML &= '</body>' & @CR
  3210. $sHTML &= '</html>'
  3211. Local $hFile = FileOpen($sTemp, $FO_OVERWRITE)
  3212. FileWrite($hFile, $sHTML)
  3213. FileClose($hFile)
  3214. If @error Then
  3215. __IEConsoleWriteError("Error", "_IECreateNewIE", "", "Error creating temporary file in @TempDir or @ScriptDir")
  3216. Return SetError($_IESTATUS_GeneralError, 2, 0)
  3217. EndIf
  3218. Run(@ProgramFilesDir & "\Internet Explorer\iexplore.exe " & $sTemp)
  3219. Local $iPID
  3220. If WinWait($sTemp, "", 60) Then
  3221. $iPID = WinGetProcess($sTemp)
  3222. Else
  3223. __IEConsoleWriteError("Error", "_IECreateNewIE", "", "Timeout waiting for new IE window creation")
  3224. Return SetError($_IESTATUS_GeneralError, 3, 0)
  3225. EndIf
  3226. If Not FileDelete($sTemp) Then
  3227. __IEConsoleWriteError("Warning", "_IECreateNewIE", "", "Could not delete temporary file " & FileGetLongName($sTemp))
  3228. EndIf
  3229. Local $oObject = _IEAttach($sTemp)
  3230. _IELoadWait($oObject)
  3231. _IEPropertySet($oObject, "title", $sTitle)
  3232. Return SetError($_IESTATUS_Success, $iPID, $oObject)
  3233. EndFunc ;==>__IECreateNewIE
  3234. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3235. ; Name...........: __IETempFile
  3236. ; Description ...: Generate a name for a temporary file. The file is guaranteed not to already exist.
  3237. ; Parameters ....: $sDirectoryName optional Name of directory for filename, defaults to @TempDir
  3238. ; $sFilePrefix optional File prefixname, defaults to "~"
  3239. ; $sFileExtension optional File extenstion, defaults to ".tmp"
  3240. ; $iRandomLength optional Number of characters to use to generate a unique name, defaults to 7
  3241. ; Return values .: Filename of a temporary file which does not exist.
  3242. ; Author ........: Dale (Klaatu) Thompson
  3243. ; Modified.......: Hans Harder - Added Optional parameters
  3244. ;
  3245. ; Adapted from excellent _TempFile() in File.au3 for IE.au3 by Dale Hohm
  3246. ; ===============================================================================================================================
  3247. Func __IETempFile($sDirectoryName = @TempDir, $sFilePrefix = "~", $sFileExtension = ".tmp", $iRandomLength = 7)
  3248. Local $sTempName, $iTmp = 0
  3249. ; Check parameters
  3250. If Not FileExists($sDirectoryName) Then $sDirectoryName = @TempDir ; First reset to default temp dir
  3251. If Not FileExists($sDirectoryName) Then $sDirectoryName = @ScriptDir ; Still wrong then set to Scriptdir
  3252. ; add trailing \ for directory name
  3253. If StringRight($sDirectoryName, 1) <> "\" Then $sDirectoryName = $sDirectoryName & "\"
  3254. ;
  3255. Do
  3256. $sTempName = ""
  3257. While StringLen($sTempName) < $iRandomLength
  3258. $sTempName = $sTempName & Chr(Random(97, 122, 1))
  3259. WEnd
  3260. $sTempName = $sDirectoryName & $sFilePrefix & $sTempName & $sFileExtension
  3261. $iTmp += 1
  3262. If $iTmp > 200 Then ; If we fail over 200 times, there is something wrong
  3263. Return SetError($_IESTATUS_GeneralError, 1, 0)
  3264. EndIf
  3265. Until Not FileExists($sTempName)
  3266. Return $sTempName
  3267. EndFunc ;==>__IETempFile
  3268. #EndRegion ProtoType Functions