SmOke_N

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

19 posts in this topic




It looks very interesting

I'll be testing your UDF in the new year.

Thanks fo sharing.

Best regards

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  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 *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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

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 *

"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: 2017-06-04

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

ie 11 browser

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by Iczer

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

working thank you

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#16 ·  Posted (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 by Scriptonize

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.