Moderators Popular Post SmOke_N Posted December 19, 2014 Moderators Popular Post Share Posted December 19, 2014 (edited) _IEJS has been deprecated, please see: These are a few functions I've put together either for current necessity, past necessity, or looking forward at possible future necessity (and no, I didn't see how many lines of code it was until I was putting this together to upload). Issues with interacting with all types of IE versions and in all types of modes (standard or quirks), and trying to develop the means to successfully drag and drop automated are what started me on this javascript injection method. But keep in mind, not all functions make use of JS. I tried to make it as inline with the IE.au3 library as I was comfortable with. Right now, there are no only a few example codes, there are headers for each function other than internal functions. Some functions (specifically the position ones) are either untested, have proven to be a pain with visible document area only issues, or are in conflict with other types of position functions. I've not had time to debug those and see where their benefit lie at the moment. I've not been able to successfully implement a drag and drop (moving one object to another objects location, firing all necessary events) scenario using the JS move/drag events or even postmessage + WM_[TYPE]BUTTONMOVE/DOWN/UP, etc, as of yet. The issue with the position functions above have been somewhat the issue. So, if you find a solution to that, let me know, if you find issues with the code, please provide a reproducer, IE version, OS Type/Arch, and AutoIt version you're running. I will not respond to "I get this error" or "It doesn't work" with nothing else. If you have javascript code and you'd like to implement, explain what it is, why it's a great idea, and we'll get it in there. Other than that... I'll get examples up as soon as I get a chance, I just knew if I didn't get it up today, I'd forget for another month or 2 years . [some Examples in Zip] Functions: expandcollapse popup_IEJS_CallObjEval() _IEJS_CallObjExecScript() _IEJS_CheckAppVersionAlways() _IEJS_ClickObjByPoint() _IEJS_CreateWithParams() _IEJS_EmbeddedGetVersion() _IEJS_EmbeddedSetVersion() _IEJS_GetAppMajorVersion() _IEJS_GetObjEval() _IEJS_GetObjParentWindow() _IEJS_GetObjPos() _IEJS_GetObjType() _IEJS_GetScroll() _IEJS_GetScrollPoint() _IEJS_GetWindowSize() _IEJS_MouseEventExec() _IEJS_JSClassNameGetArray() _IEJS_JSClassNameGetCollection() _IEJS_JSClickObj() _IEJS_JSClickObjById() _IEJS_JSClickObjByName() _IEJS_JSClickObjByPoint() _IEJS_JSDragEventObj() _IEJS_JSEnable() _IEJS_JSGetObjByClassName() _IEJS_JSGetObjPos() _IEJS_JSIsEnabled() _IEJS_JSMouseEventObj() _IEJS_JSMouseEventObjById() _IEJS_JSMouseEventObjByName() _IEJS_JSObjQuerySelector() _IEJS_JSObjQuerySelectorAll() _IEJS_JSTypeOf() _IEJS_TabAttach() _IEJS_TabCount() _IEJS_TabCreate() _IEJS_TabGetInstance() _IEJS_VersionInfo() _IEJS_WinGetBrowserObjArray() Changes: Changes from 0.0.3 - 0.0.5 have been lost! 2014-12-30 B0.0.6 Added: _IEJS_EmbeddedGetVersion(); Get the embedded version used from something like _IECreateEmbedded 2014-12-30 B0.0.6 Added: _IEJS_EmbeddedSetVersion(); Set the embedded version used from something like _IECreateEmbedded (see example) 2014-12-30 B0.0.6 Added: _IEJS_TabAttach(); Similar to _IEAttach(), but browser specific and different string cases 2014-12-30 B0.0.6 Added: _IEJS_TabCount(); Get a count of the tabs open in a specific browser session 2014-12-30 B0.0.6 Added: _IEJS_TabGetInstance(); Get the tab instance number from the specific browser session 2014-12-30 B0.0.6 Added: _IEJS_WinGetBrowserObjArray(); Get all the browser objects (tabs) from a specific browser window handle/title Fixes for next version (B0.0.7): expandcollapse popup; I mistakenly left out interacting with 3 params (attach/visible/takefocus) Func _IEJS_CreateWithParams($sURL, $sParams = "", $iTryAttach = 0, $iVisible = 1, $iWait = 1, $iTakeFocus = 1) Local Static $sHKCR = ((@AutoItX64) ? "HKCR64" : "HKCR") Local Static $szCOMIE = FileGetShortName(RegRead($sHKCR & _ "\CLSID\{0002DF01-0000-0000-C000-000000000046}\LocalServer32","")) If Not FileExists(StringReplace($szCOMIE, '"', "")) Then $szCOMIE = FileGetShortName(RegRead($sHKCR & _ "\CLSID\{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}\LocalServer32","")) If Not FileExists(StringReplace($szCOMIE, '"', "")) Then Return SetError($_IESTATUS_NoMatch, 1, 0) EndIf EndIf Local $oRet If $iTryAttach Then $oRet = _IEJS_TabAttach($sURL, "URL") If IsObj($oRet) Then $oRet.visible = $iVisible If $iVisible And $iTakeFocus Then WinActivate($oRet.hwnd) EndIf Return SetError($_IESTATUS_Success, 1, $oRet) EndIf EndIf ; get current shell windows open and their count Local $oShell = ObjCreate("Shell.Application") Local $oWin, $nCount = $oShell.windows.count() $sParams = (StringLen($sParams) > 0) ? " " & $sParams : "" Local $iTimer = TimerInit() ; set a 5 minute timeout Local $iPID = Run($szCOMIE & $sParams & ' "' & $sURL & '"') While 1 $oWin = $oShell.windows() If $oWin.count() <> $nCount Then $nCount = $oWin.count() $oRet = $oWin($nCount - 1) If $oRet.TopLevelContainer Then ExitLoop EndIf If (TimerDiff($iTimer) / 1000) >= 300 Then ; timed out waiting, close IE instance ProcessClose($iPID) Return SetError($_IESTATUS_LoadWaitTimeout, 2, 0) EndIf Sleep(10) WEnd If Not $iVisible Then $iTakeFocus = 0 $oRet.visible = False EndIf If $iTakeFocus Then WinActivate($oRet.hwnd) EndIf If $iWait Then _IELoadWait($oRet) If @error Then Return SetError(@error, 3, $oRet) EndIf EndIf Return SetError($_IESTATUS_Success, 2, $oRet) EndFunc ;==>_IEJS_CreateWithParams 2014-12-21: IEJS.B003.zip 2014-12-23: IEJS.B004.zip 2014-12-29: IEJS.B005.zip 2014-12-30: IEJS.B006.zip Edited January 26, 2015 by SmOke_N coffeeturtle, Gianni, mesale0077 and 2 others 5 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mLipok Posted December 19, 2014 Share Posted December 19, 2014 It looks very interesting I'll be testing your UDF in the new year. Thanks fo sharing. Best regards mLipok Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
mesale0077 Posted December 20, 2014 Share Posted December 20, 2014 OS:WIN_81/ CPU:X64 OS:X64 autoit stabil version and beta version error !>23:49:47 AutoIt3.exe ended.rc:-1073741571 --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop !>23:49:47 AutoIt3.exe ended.rc:-1073741571 +>23:49:47 AutoIt3Wrapper Finished. >Exit code: 3221225725 Time: 10.07 Eval Example: ClassName Array Example: ClassName Collection Example: querySelector and Click Example: dont work why? thank you now. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 20, 2014 Author Moderators Share Posted December 20, 2014 (edited) Hi mesale007, Unfortunately, I do not have that system setup around to debug that in. I'm utilizing someone else's pc for the next few weeks with no access to even a vm win8. Out of curiosity, are you running IE11? Edit: I assume you mean current stable and beta versions? Edited December 20, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
mesale0077 Posted December 20, 2014 Share Posted December 20, 2014 ie 11 browser Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 20, 2014 Author Moderators Share Posted December 20, 2014 You'll notice in the the comments from the main funcs (eval/execscript), that I had a concern with IE11, I have had zero chance to debug or use it. Maybe you can step through the code in spots and see where it fails. Otherwise, I won't be able to do much for some time. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Iczer Posted December 21, 2014 Share Posted December 21, 2014 (edited) For some reason this code do not work - i want image context menu to appear $oIE = _IEAttach (WinGetTitle ( $hWnd_S ), 'Embedded',1) $oImgs = $oIE.document.images For $oImg In $oImgs ..... $PICFrameSize = _IEJS_GetObjPos($oImg) If $PICFrameSize[1] < 0 Then $PICFrameSize[1] = 0 $PICFrameSize[0] += $IESWindowSize[0] + _WinAPI_GetSystemMetrics(32) $PICFrameSize[1] += $TBSWindowSize[3]+ $IESWindowSize[1] + _WinAPI_GetSystemMetrics(4) Local $redyState = $oImg.readyState ConsoleWrite("$oImg.readyState PRE = "&$redyState&@CRLF) If $redyState == "uninitialized" Then _IEJS_JSMouseEventObj($oIE, $oImg, "ContextMenu",$PICFrameSize[0],$PICFrameSize[1]) ConsoleWrite("error = "&@error&@CRLF) there are no error: $oImg.readyState PRE = uninitialized error = 0 ie in my case - embedded IE6 Edited December 21, 2014 by Iczer Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 21, 2014 Author Moderators Share Posted December 21, 2014 (edited) Iczer, if I can't replicate it with working reproducer code, I can't help to debug it. Good luck. Edit: FYI, there is no point call for contextmenu btw. the x & y positions being passed are not relevant. Edit2: I think I found the issue in the JS code. Me getting ahead of myself I believe. I'll fix that and add contextmenupoint func (not sure it'll work though, you can test when it's up). I have one or two other things I'm working on fixing at the moment as well before I upload. Edited December 21, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2014 Author Moderators Share Posted December 22, 2014 Ok Iczer and mesale0077, give your perspective scripts a try. @Iczer, you'll have to change your: _IEJS_JSMouseEventObj($oIE, $oImg, "ContextMenu",$PICFrameSize[0],$PICFrameSize[1]) To _IEJS_JSMouseEventObj($oIE, $oImg, "ContextMenuPoint",$PICFrameSize[0],$PICFrameSize[1]) @mesale0077, I'm unsure if the change I made to the app version is going to help you, but it shouldn't hurt. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Iczer Posted December 22, 2014 Share Posted December 22, 2014 hmm... it still cannot make context menu to appear, but now i get: $oImg.readyState PRE = uninitialized error = 7 extended = 3 _IEJS_JSMouseEventObj($oIE, $oImg, "ContextMenuPoint",$PICFrameSize[0],$PICFrameSize[1]) _IEJS_JSMouseEventObj($oIE, $oImg, "ContextMenuPoint") it seems it cannot find image... but $oImg.scrollIntoView() and _IEJS_GetObjPos($oImg) are working OK Link to comment Share on other sites More sharing options...
mesale0077 Posted December 22, 2014 Share Posted December 22, 2014 working thank you Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2014 Author Moderators Share Posted December 22, 2014 @mesale0077, good deal, thank you. @Iczer, I cannot replicate your situation/issue as you know by now. expandcollapse popup#include "IEJS.au3" ; disregard _IEAttach console error if instance doesn't exist yet Global $goIE = _IECreate("http://www.javascripttoolbox.com/lib/contextmenu/", 1) _ExampleContextMenu($goIE) ConsoleWrite(@error & ":" & @extended & @CRLF) ;_IEQuit($goIE) Func _ExampleContextMenu(ByRef $oObj) If Not IsObj($oObj) Then Return SetError(1, 0, 0) EndIf Local $oDivContainer = _IEJS_JSObjQuerySelector($oObj, 'div[class="context-menu ' & _ 'context-menu-theme-vista context-menu-example-trigger menu-vista"]') If Not IsObj($oDivContainer) Then Return SetError(2, 0, 0) EndIf Local $oDivOuter = _IEJS_JSGetObjByClassName($oDivContainer, "context-menu-item", "div") If @error Then Return SetError(3, 0, 0) EndIf $oDivOuter.scrollIntoPoint() ; point with no coordinates is defaulted to center ; however, some context events check the mouse position instead of the ; object position, in order to determine where to put the contextMenu popup Local $iRet = _IEJS_JSMouseEventObj($oObj, $oDivOuter, "contextMenuPoint") IF @error Then Return SetError(@error, @extended, $iRet) EndIf Return 1 EndFunc This works as expected because they have an event for onContextMenu. I'm also putting this in examples. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 23, 2014 Author Moderators Share Posted December 23, 2014 I've added a couple of new funcs. _IEJS_TabCreate(); I've seen often people wanting to know how to manage working in tabs, this will come in handy for those people. _IEJS_MouseEventExec(); This does not use your physical mouse, it doesn't utilize JS, it utilizes postMessage and the WM_M* calls. I have an example of it working really well (contextMenu even centers) in the Examples folder I just uploaded, it's called: IEJSMouseEventGetPosGetScroll.au3 (should read IEJSMouseEventGetPosGetScrollExample.au3 oops). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 29, 2014 Author Moderators Share Posted December 29, 2014 Fixed 2 functions added feature to get embedded IE major version as well. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 30, 2014 Author Moderators Share Posted December 30, 2014 2014-12-30 B0.0.6 Added: _IEJS_EmbeddedGetVersion(); Get the embedded version used from something like _IECreateEmbedded 2014-12-30 B0.0.6 Added: _IEJS_EmbeddedSetVersion(); Set the embedded version used from something like _IECreateEmbedded (see example) 2014-12-30 B0.0.6 Added: _IEJS_TabAttach(); Similar to _IEAttach(), but browser specific and different string cases 2014-12-30 B0.0.6 Added: _IEJS_TabCount(); Get a count of the tabs open in a specific browser session 2014-12-30 B0.0.6 Added: _IEJS_TabGetInstance(); Get the tab instance number from the specific browser session 2014-12-30 B0.0.6 Added: _IEJS_WinGetBrowserObjArray(); Get all the browser objects (tabs) from a specific browser window handle/title Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Scriptonize Posted January 22, 2015 Share Posted January 22, 2015 (edited) Hi, I'm getting this error while using IEJS.au3: Files (x86)\AutoIt3\Include\IEJS.au3" (555) : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.: I'm trying to use it with this call: Local $hBtn $hBtn = _IEJS_JSGetObjByClassName($oIE,"buttonLink100",Default,Default) Am I using the function correctly. Thanx in advance for your time. [Edit] I'm using version IEJS.B006.zip Edited January 22, 2015 by Scriptonize If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 22, 2015 Author Moderators Share Posted January 22, 2015 Hi scriptonize, There's only one place where it can have a recurse issue. Thought I may have fixed that issue to be honest when checking for versioning. I had foreseen a possible issue with people that are using IE11, as execScript was removed by microsoft. I assume you are also using IE11? I am also going to be locking this thread soon, I have many more functions to add, but I'm changing this to IEEx.au3 as I will be having many standard, javascript, and possibly jquery functions later on down the line. So any foresight you can offer I'd appreciate (eg. IE version, IE update version , AutoIt version, and anything else you may deem important to know). For now, this is a new function that will be added to the IEEx.au3 that uses standard properties, it returns an array, so you'd have to cycle through an array of objects rather than use the object specifically. Where you'd normally do (pseudo): $oClass = _class_function_here() ConsoleWrite($oClass.id & @CRLF) You'd do: $aOClass = _arrayclass_function_here() ConsoleWrite($aOClass[n].id & @CRLF) expandcollapse popup;================================================================================================================================ ; ; Function Name....: _IEEx_ClassNameGetArray(ByRef $oObj, $sClass, $sTag = Default, $iIndex = Default) ; Description......: ; Parameter(s).....: ; $oObj: The document/form/browser/window object you're working with ; $sClass: The class string you want to find ; $sTag: [Optional: Default = Empty String], the tag name type you want to search in ; $iIndex: [Optional: Default = -1 (All Found)]; The index number you want to return ; Return Value(s)..: ; Success...: An array of objects found by class name ; Failure...: 0 ; Error.....: 0 = Success, error returns taken from IE.au3 ; 1 = General Error, 2 = COM Error, 3 = Invalid Data Type ; 4 = Invalid Object Type, 5 = Invalid Value ; 6 = Load Wait Timeout, 7 = No Match, 8 = Access Denied ; Extended..: the number returned is for debugging only, there is data ; returned for both success and failures, it marks the part ; of the code for easier debugging ; Requirement(s)...: ; Author(s)........: SmOke_N (Ron Nielsen) Ron.SMACKThatApp@gmail.com ; Modified.........: ; Comment(s).......: ; Example(s).......: ; ;================================================================================================================================ Func _IEEx_ClassNameGetArray(ByRef $oObj, $sClass, $sTag = Default, $iIndex = Default) ; returns an array of objects If Not IsObj($oObj) Then Return SetError($_IESTATUS_InvalidDataType, 1, 0) EndIf $iIndex = (IsKeyword($iIndex) Or $iIndex < 0) ? -1 : $iIndex $sTag = (IsKeyword($sTag) Or Not StringLen($sTag)) ? "" : $sTag Local $oTags = (StringLen($sTag)) ? _IETagNameGetCollection($oObj, $sTag, $iIndex) : _ _IETagNameAllGetCollection($oObj, $iIndex) Local $iExtended = @extended If Not IsObj($oTags) Then Return SetError($_IESTATUS_NoMatch, 2, 0) EndIf Local $aORet[$iExtended], $iCount If $iIndex = -1 Then For $oTag In $oTags If String($oTag.classname) = $sClass Then $aORet[$iCount] = $oTag $iCount += 1 EndIf Next Else $aORet[$iCount] = $oTags.index($iIndex) If Not IsObj($aORet[$iCount]) Then Return SetError($_IESTATUS_InvalidValue, 3, 0) EndIf $iCount += 1 EndIf If Not $iCount Then Return SetError($_IESTATUS_NoMatch, 4, 0) EndIf ReDim $aORet[$iCount] Return SetError($_IESTATUS_Success, 1, $aORet) EndFunc ;==>_IEEx_ClassNameGetArray . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Scriptonize Posted January 23, 2015 Share Posted January 23, 2015 Hi Smoke_N Thank you for replying. You are right, I'm using IE11 (11.0.9600.17501) The update version number of IE is: 11.0.15 For AutoItScript, I'm using 3.3.12.0 My OS is Windows 7 Enterprise (V6.1.7601 Service pack 1) 64 bits. That's all I can think of what might be useful. If you learn from It, it's not a mistake Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 26, 2015 Author Moderators Share Posted January 26, 2015 _IEJS has been deprecated, please see: Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts