3nhu1 Posted May 16, 2007 Share Posted May 16, 2007 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 CODEFor $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 More sharing options...
Davo Posted May 16, 2007 Share Posted May 16, 2007 (edited) 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 itCODEFor $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","") NextMsgBox(0,"", "Complete")Hi,You are not using the correct syntax for the for statement.syntax:For $i = startNumber To FinishNumber Step ValueNextIn your case you want the "value" to be 1 to loop through all values between start and finish numbersegCODEFor $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","") NextMsgBox(0,"", "Complete")DaveEdited to add codebox example Edited May 16, 2007 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 More sharing options...
3nhu1 Posted May 16, 2007 Author Share Posted May 16, 2007 Hi Davo, thanks for the comment. I changed the code but the problem remains unchanged, i didnt add in the step value previously as the default is 1 already. Link to comment Share on other sites More sharing options...
Davo Posted May 16, 2007 Share Posted May 16, 2007 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 More sharing options...
3nhu1 Posted May 16, 2007 Author Share Posted May 16, 2007 the debug option is really useful and it showed the true problem the script was actually stuck waiting for one of the windows to open. thanks Davo for your helpfulness Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now