Jump to content

Something with While goes wrong?


 Share

Recommended Posts

Hi all, I have made the following script:

While 1
    


Sleep(100)

Run("C:\Program Files\Mozilla Firefox\firefox.exe [a URL]")
WinWaitActive("Mozilla Firefox")
Sleep(2000)
MouseClick ( "left" , 400, 488 , 1 , 5  ) 
WinWaitActive("Mozilla Firefox")
WinSetState("Mozilla Firefox", "", @SW_MAXIMIZE)
Sleep(2000)



Sleep(2000)
MouseClick ( "left" , 25, 750 , 1 , 0  ) 
MouseClick ( "left" , 100, 680 , 1 , 1  )
Send("file:///C:/Documents%20and%20Settings/Administrator/Desktop/start.txt {Enter}")
Sleep(1000)
WinSetState("farm -", "", @SW_MAXIMIZE)
Sleep(400)
MouseMove ( 900, 45 , 5 ) 
MouseDown ( "left" )
MouseMove ( 5, 45 , 5 )
MouseUp("left")
Send ("^X")
Send ("{DELETE}")
$cop = ClipGet() 
$array=StringSplit ( $cop, "|" ) 
While $Array[0] < 10
WinActivate ( "farm -")
Sleep(400)
MouseMove ( 900, 45 , 5 ) 
MouseDown ( "left" )
MouseMove ( 5, 45 , 5 )
MouseUp("left")
Send ("^X") 
Send ("{DELETE}")

$cop = ClipGet() 
$array=StringSplit ( $cop, "|" ) 

;Go to the browser...
Sleep(2000)
WinActivate ( "Mozilla Firefox")
WinSetState ( "Mozilla Firefox", " ", @SW_MAXIMIZE)


MouseClick ( "left" , 500, 65 , 1 , 5  )

Send("^a")
Send($Array[1]) 
Send("{ENTER}")
WinWaitActive("Mozilla Firefox")
Sleep(2000)
;The next part will go to the input boxes and fill them in...
MouseClick ( "left" , 200, 310 , 1 , 0  );to 1st
Send($Array[2])
Sleep(200)
MouseClick ( "left" , 200, 333 , 1 , 0  );to 2nd 
Send($Array[3])
Sleep(200)
MouseClick ( "left" , 200, 355 , 1 , 0  );to 3rd
Send($Array[4])
Sleep(200)
MouseClick ( "left" , 333, 310 , 1 , 0  );to 4rd
Send($Array[5])
Sleep(200)
MouseClick ( "left" , 333, 333 , 1 , 0  );to 5.
Send($Array[6])
Sleep(200)
MouseClick ( "left" , 333, 355 , 1 , 0  );to 6.
Send($Array[7])
Sleep(200)


MouseClick ( "left" , 171, 439 , 1 , 0  ) 
Sleep(200)
MouseClick ( "left" , 180, 490 , 1 , 0  ) 
Sleep(2000)
MouseClick ( "left" , 180, 450 , 1 , 0  ) 


Sleep(10000)
WEnd 

MsgBox(0,"yes","it works")

Winclose("Notepad")
WinClose("Firefox")

Sleep(30000) 
WEnd

As you can see, this script starts and it gets some data from the notepad. I take it into different strings, this works fine.

On a web form, I could fill this info in. After the list is done, I have made much delimiters so $Array[0] > 10.

The next part should be launched (after the first WEnd.), which will restart the program completely. But when While $Array[0] > 10, it just stops.

the next part does NOT launch, I dont get the MsgBox(0,"yes","it works"). It just stops. I dont know why.

This should be exactly the same as

While 1
$a = 0
MsgBox(0,"hi", "hello") 
While $a < 10
$a=$a+1
Msgbox(0,"Hi", "Looping")
WEnd
MsgBox(0,"hi","Hello2")
WEnd

But it isnt it doesnt work :D

Edited by Sim0n
Link to comment
Share on other sites

So many reasons...

While $Array[0] < 10

The above statement is always true (since it enters the While). Why use an array if you are not going to traverse it?

You are also updating the array within the While:

$cop = ClipGet()

$array=StringSplit ( $cop, "|" )

Here is how you should be using it:

$cop = ClipGet() 
$array=StringSplit ( $cop, "|" ) 
$j = ubound($array)
$i = 0
While $i < $j
 ; Do stuff using the array contents
   Send($Array[$i])
   Sleep(200)
  ; Do not change the Array bounds within the While Loop !
Wend
Edited by DaRam
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...