Jump to content

autoit javascript error


Go to solution Solved by bogQ,

Recommended Posts

Posted

Hi!

Im trying to get an element from a page using javascript in autoit, searching the forum i didnt find much about the subject.

I tryed this simple example 

#include <IE.au3>
#include <MsgBoxConstants.au3>
Local $oIE, $oElem

$oIE = _IECreate("https://www.autoitscript.com/site/", 0, 0)
$oElem = $oIE.document.getElementsByTagName('p')[1].innerText
msgbox(0, "", $oElem)

In a javascript console document.getElementsByTagName('p')[1].innerText gives "AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting..."

But when i try in autoit it gives the error 

(6) : ==> Subscript used on non-accessible variable.:
$oElem = $oIE.document.getElementsByTagName('p')[1].innerText
$oElem = $oIE.document.getElementsByTagName('p')^ ERROR
 
Can someone help?
 
Posted

you need to check do  $oIE.document.getElementsByTagName('p') return array?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
  • Solution
Posted

$oElem = $oIE.document.GetElementsByTagName("p").item(1).innerText()

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Posted (edited)

#include <IE.au3>

#include <MsgBoxConstants.au3>

Local $oIE, $oElem

$oIE = _IECreate("https://www.autoitscript.com/site/", 0, 1, 1)
$oElem = $oIE.document.GetElementsByTagName("p").item(1).innerText()

MsgBox(0, "", $oElem)

EDIT: bogQ beat me to it ;)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

.innerText is property, not method. That means the last set of parentheses shouldn't be there.
Also, .item is default property, meaning it can be omitted:

$oIE.document.GetElementsByTagName("p")(1).innerText

...Disable buggy AU3Check before running that.

♡♡♡

.

eMyvnE

Posted

cheating.jpg

:)

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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