Jump to content

IEJS - IE Javascript options, an IE.au3 personal extension


SmOke_N
 Share

Recommended Posts

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 Codefor 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 APIErrorLog.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 TaskSchedulerIE 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 stuffOnHungApp handlerAvoid "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"
:naughty:  :ranting:, 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

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

  • Moderators

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 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

  • Moderators

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

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 by Iczer
Link to comment
Share on other sites

  • Moderators

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 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

  • Moderators

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

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

  • Moderators

@mesale0077, good deal, thank you.

@Iczer, I cannot replicate your situation/issue as you know by now.

#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

  • Moderators

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

  • Moderators

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

  • Moderators

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

  • 4 weeks later...

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 by Scriptonize

If you learn from It, it's not a mistake

Link to comment
Share on other sites

  • Moderators

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)
;================================================================================================================================
;
; 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

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

  • Moderators

_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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...