Jump to content

Only loops once help


Recommended Posts

Hi I'm new to autoit and have run into some problems. In the code below, it only loops once. eg from finishing 152 and 153 but it doesnt continue on to 154 and 155. Could you have a look and tell me whats wrong?

Thanks I really appreciate it

CODE
For $i = 152 to 155

;Input folder

WinActivate("File Sort - ImportExport","")

Send("{tab 4}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Output folder

Send("{tab 2}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Click on Sort Files

Send("{tab 5}",0)

Sleep(1000)

Send("{Space}",0)

Winwait("File Sort - Import Export - ImportExport" ,"")

Winactivate("File Sort - Import Export - ImportExport" ,"")

Winwaitactive("File Sort - ImportExport","")

Next

MsgBox(0,"", "Complete")

Link to comment
Share on other sites

Hi I'm new to autoit and have run into some problems. In the code below, it only loops once. eg from finishing 152 and 153 but it doesnt continue on to 154 and 155. Could you have a look and tell me whats wrong?

Thanks I really appreciate it

CODE
For $i = 152 to 155

;Input folder

WinActivate("File Sort - ImportExport","")

Send("{tab 4}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Output folder

Send("{tab 2}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Click on Sort Files

Send("{tab 5}",0)

Sleep(1000)

Send("{Space}",0)

Winwait("File Sort - Import Export - ImportExport" ,"")

Winactivate("File Sort - Import Export - ImportExport" ,"")

Winwaitactive("File Sort - ImportExport","")

Next

MsgBox(0,"", "Complete")

Hi,

You are not using the correct syntax for the for statement.

syntax:

For $i = startNumber To FinishNumber Step Value

Next

In your case you want the "value" to be 1 to loop through all values between start and finish numbers

eg

CODE
For $i = 152 to 155 Step 1

;Input folder

WinActivate("File Sort - ImportExport","")

Send("{tab 4}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Output folder

Send("{tab 2}",0)

Send("C:\BIR\images\SS" & $i & "a_raw{Enter}")

Sleep(2000)

;Click on Sort Files

Send("{tab 5}",0)

Sleep(1000)

Send("{Space}",0)

Winwait("File Sort - Import Export - ImportExport" ,"")

Winactivate("File Sort - Import Export - ImportExport" ,"")

Winwaitactive("File Sort - ImportExport","")

Next

MsgBox(0,"", "Complete")

Dave

Edited to add codebox example

Edited by Davo

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Link to comment
Share on other sites

Hmm I didn't realise it was optional, my bad. Anyhow, the problem is probably not from the loop in that case. I suggest you add an option at the top of the script to debug to tray icon.

The code is

Opt("TrayIconDebug",1)

This will show the line of code being executed when you put your cursor on the autoit icon in the taskbar.

I have a feeling its not to do with your for statement, its probably waiting for a window to activate that never activates.

Also I would suggest adding a message box as the top of each for loop to ensure the value of $i is changing.

msgbox(0,"",$i)

This should narrow the problem down :)

Dave

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

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