Jump to content
Sign in to follow this  
JonM

FOR loop counter seems to go down too fast

Recommended Posts

JonM

My script:

For $i = 90 to 1 Step -1

WinWaitActive("JPEG Option")

SEND("8{ENTER}")

Next

Needs a counter at least twice as big as the number of times I want it to run. In above example this script only runs on 43 files and not all 90.

If it is meaningful this script is when I am running a photoshop automate action.

Tried a few searches of forum but probably using wrong keywords as didn't find anything.

Any help appreciated.

Share this post


Link to post
Share on other sites
BrettF

My script:

For $i = 90 to 1 Step -1

WinWaitActive("JPEG Option")

SEND("8{ENTER}")

Next

Needs a counter at least twice as big as the number of times I want it to run. In above example this script only runs on 43 files and not all 90.

If it is meaningful this script is when I am running a photoshop automate action.

Tried a few searches of forum but probably using wrong keywords as didn't find anything.

Any help appreciated.

Is that your whole script? I'm thinking its the program that is having a problem.

Share this post


Link to post
Share on other sites
therks

I would guess that perhaps the window does not disappear or become inactive fast enough after the Send, so what's happening is it loops twice before the window disappears.

Try adding something to check if the window has closed, or changed somehow before continuing the loop. Maybe something like

For $i = 90 to 1 Step -1
  WinWaitActive("JPEG Option") 
  SEND("8{ENTER}")
  WinWaitClose("JPEG Option")
Next

Share this post


Link to post
Share on other sites
JonM

I would guess that perhaps the window does not disappear or become inactive fast enough after the Send, so what's happening is it loops twice before the window disappears.

Try adding something to check if the window has closed, or changed somehow before continuing the loop. Maybe something like

For $i = 90 to 1 Step -1
  WinWaitActive("JPEG Option") 
  SEND("8{ENTER}")
  WinWaitClose("JPEG Option")
Next
Many thanks, the WinWaitClose has solved my problem. I had assumed the WinWaitActive needed a new instance.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.