Jump to content

do loop in a do loop


Recommended Posts

hi this is my code

what im trying to do is that the

Until $state = "Done"

happens 3 times

is loop till this happens then carry on with the function

cheers for any help

Opt("WinTitleMatchMode", 2)
#include <IE.au3>
$file = FileOpen("C:\loader\input.dat", 0)
$line = FileReadLine($file)
$username = $line
$line = FileReadLine($file)
$password = $line
FileClose($file)
WaitLoad()
Func WaitLoad()
    Dim $state
     $oIE = _IECreate ("webaddress")
     WinSetState("[class:IEFrame]","",@SW_MAXIMIZE) 
     _IELoadWait($oIE)
    WinActivate("[class:IEFrame]","")
    Do
    $state = StatusbarGetText("[class:IEFrame]","")
Until $state = "Done"
    ;sleep(8000)
    winactivate ("[class:IEFrame]","")
winwaitactive ("[class:IEFrame]","")
$o_form = _IEFormGetObjByName ($oIE, "frmlogin")
$o_login = _IEFormElementGetObjByName ($o_form, "username")
$o_password = _IEFormElementGetObjByName ($o_form, "password")
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEFormSubmit ($o_Form)
EndFunc
Link to comment
Share on other sites

just a thought...

Opt("WinTitleMatchMode", 2)
#include <IE.au3>
$file = FileOpen("C:\loader\input.dat", 0)
$line = FileReadLine($file)
$username = $line
$line = FileReadLine($file)
$password = $line
FileClose($file)
WaitLoad()
Func WaitLoad()
    Dim $state
    $oIE = _IECreate("webaddress")
    WinSetState("[class:IEFrame]", "", @SW_MAXIMIZE)
    _IELoadWait($oIE)
    WinActivate("[class:IEFrame]", "")
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
    ;sleep(8000)
    WinActivate("[class:IEFrame]", "")
    WinWaitActive("[class:IEFrame]", "")
    $o_form = _IEFormGetObjByName($oIE, "frmlogin")
    $o_login = _IEFormElementGetObjByName($o_form, "username")
    $o_password = _IEFormElementGetObjByName($o_form, "password")
    _IEFormElementSetValue($o_login, $username)
    _IEFormElementSetValue($o_password, $password)
    _IEFormSubmit($o_form)
EndFunc   ;==>WaitLoad

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Best guess at what you're asking-

Opt("WinTitleMatchMode", 2)
#include <IE.au3>
$file = FileOpen("C:\loader\input.dat", 0)
$line = FileReadLine($file)
$username = $line
$line = FileReadLine($file)
$password = $line
FileClose($file)
Dim $state
$oIE = _IECreate ("webaddress")
WinSetState("[class:IEFrame]","",@SW_MAXIMIZE) 
_IELoadWait($oIE)
WinActivate("[class:IEFrame]","")
for $i=1 to 3
    Do
        $state = StatusbarGetText("[class:IEFrame]","")
    Until $state = "Done"
Next
winactivate ("[class:IEFrame]","")
winwaitactive ("[class:IEFrame]","")
$o_form = _IEFormGetObjByName ($oIE, "frmlogin")
$o_login = _IEFormElementGetObjByName ($o_form, "username")
$o_password = _IEFormElementGetObjByName ($o_form, "password")
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEFormSubmit ($o_Form)
Link to comment
Share on other sites

cheers guys thanks for your help

herewasplato that worked but i had to add a sleep inbetween them

Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
sleep(5000)
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
sleep(5000)
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
sleep(1000)

evilertoaster

i think this would have worked but because the states bar says done for a while the loop comes round to quick it counts the first Done Again

for $i=1 to 3
    Do
        $state = StatusbarGetText("[class:IEFrame]","")
    Until $state = "Done"

thanks again really apreacate it

Link to comment
Share on other sites

> the loop comes round to quick it counts the first Done Again

For $i = 1 To 3
    Do
        $state = StatusbarGetText("[class:IEFrame]", "")
    Until $state = "Done"
    Sleep(5000)
Next
...then add a sleep

See if you can glean anything from this really old code of mine:

While 1
    $cnt = 0
    $tot = 50
    For $done = 1000 To 0 Step -1
        TrayTip($done, "Waiting on Done" & @CR & $cnt & " of " & $tot, 10)
        Sleep(10)
        If WinExists(, "Done") Then
            $cnt += 1
            If $cnt = $tot Then ExitLoop 2
        Else
            $cnt = 0
        EndIf
        If WinExists("Cannot find server") Then
            WinClose("Cannot find server")
            ShellExecute("some URL")
        EndIf
    Next
    WinActivate("some title")
    WinWaitActive("some title")
    Send("{F5}")
WEnd
TrayTip("", "", 1)
For the site that I was working with, the "Done" came and went many times before the page finished loading and the number of times varied. The code above came from a script that has nothing to do with the IE UDF set.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
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
 Share

  • Recently Browsing   0 members

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