Sign in to follow this  
Followers 0
MacBain00

String & Array Help

4 posts in this topic

Hi all,

I'm creating another script, but I was wondering if it is possible to do the following:

1) Create an array with all the DOM locations of fields in IE

2) Use a for loop to call them

Example:

CODE

Global $step[3]

$step[0] = 'document.forms.LoginForm.LoginButton.click'

$step[1] = 'document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl3_hpObject").click'

$step[2] = 'document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl13_hpObject").click'

$Top=ObjCreate("InternetExplorer.Application.1")

With $Top

Sleep(3000)

.Visible=1

.Height=(@DesktopHeight-50)

.Height=(@DesktopHeight-50)

.Width=(@DesktopWidth-50)

.Silent=1 ; Don't show IE's dialog boxes

EndWith

For $j = 0 To 3

_BeginTimer()

$Top.$step[$j] <-- this is what is always erroring. says "=" is expected. is this at all possible?

_EndTimer($Top)

Next

Thanks for any help on this.


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites



I don't know anything about the IE functions etc but the way you're trying to do things definitely won't work.

Possibly you could do something like this but I haven't tried it.

Global $step[3]
$step[0] = '$Top.document.forms.LoginForm.LoginButton.click'
$step[1] = '$Top.document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl3_hpObject").click'
$step[2] = '$Top.document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl13_hpObject").click'

$Top=ObjCreate("InternetExplorer.Application.1") 
    With $Top
        Sleep(3000)
        .Visible=1
        .Height=(@DesktopHeight-50)
        .Height=(@DesktopHeight-50)
        .Width=(@DesktopWidth-50)
        .Silent=1         ; Don't show IE's dialog boxes
    EndWith

For $j = 0 To 3
    _BeginTimer()
    Execute($step[$j])   
    _EndTimer($Top)
Next

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm trying to create a script that navigates though a URL with a specific number of steps; each waiting for the previous step to complete before the step starts. The page has frames so that makes it a little bit more different to wait for all frames to finish loading because starting the next step. This is what i have so far, but it keeps going to the next step without waiting for the previous step to complete. I need to figure out how to force it to look for the ObjEvent before moving to the next step. Any help would be appreciated.

CODE

#include <IE.au3>

#include <Array.au3>

#include <String.au3>

#Include <File.au3>

Global $Timer

Global $i = 0

Global $step[15]

$address = "URL"

$username = "LOGIN"

$password = "PASSWORD"

$inifile = @ScriptDir & "\" & "output" & @HOUR & @MIN & @SEC & ".ini"

$section = @MON & @MDAY & @YEAR & @HOUR & @MIN & @SEC

$step[0] = '$Top.document.forms.LoginForm.LoginButton.click'

$step[1] = '$Top.document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl3_hpObject").click'

$step[2] = '$Top.document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl13_hpObject").click'

$step[3] = '$Top.document.frames.main.document.getElementById("ListDisplayNavigation_dgObjects__ctl3_hpObject").click'

If Not _FileCreate($inifile) Then

MsgBox(4096,"Error"," Error Creating Output File. error:" & @error)

Exit

EndIf

$Top=ObjCreate("InternetExplorer.Application.1")

With $Top

Sleep(3000)

.Visible=1

.Height=(@DesktopHeight-50)

.Height=(@DesktopHeight-50)

.Width=(@DesktopWidth-50)

.Silent=1 ; Don't show IE's dialog boxes

EndWith

Sleep(3000)

$EventObject=ObjEvent($Top,"IEEvent_","DWebBrowserEvents")

_BeginTimer()

_IENavigate($Top,$address)

$Top.document.forms.LoginForm.UserLoginBox.value=$username

$Top.document.forms.LoginForm.UserPasswordBox.value=$password

For $j = 0 To 3

_BeginTimer()

Execute($step[$j])

Next

Exit

Func IEEvent_NavigateComplete($1)

_EndTimer()

EndFunc

Func _BeginTimer()

$Timer = TimerInit()

EndFunc

Func _EndTimer()

$dif = (TimerDiff($Timer)/1000)

IniWrite($inifile,$section,"Step" & $j,$dif)

$j = $j + 1

Sleep(3000)

EndFunc

Edited by MacBain00

-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

Anybody?


-Work Smarter, Not Harder, Use More AutoIT

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0