Jump to content

Loop


Recommended Posts

Hello,

How can I let the program restart from a point when the script has finished? For example: Your program writes a document in Word and if it has finished with it it starts over, but it only repeats the commands between /1 and /1

Thanks

Edited by PcExpert
Link to comment
Share on other sites

  • Moderators

Hello,

How can I let the program restart from a point when the script has finished? For example: Your program writes a document in Word and if it has finished with it it starts over, but it only repeats the commands between /1 and /1

Thanks

Make it a conditional statement... If something is True Then Do Commands ... If it isn't true then it will just continue the loop.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

@smoke_n an if-case isn't a loop a loop is sth like while-wend or for-next!

@pcexpert for what do you exactly use the loo? there are some loops:

- the while-loop, which repeats while it has a special value for example.

- the for-loop, which repeats until a special value for a variable has reached

- and the do-loop, which conditions are like the one from the for:

Do...Until

--------------------------------------------------------------------------------

Loop based on an expression.

Do

statements

...

Until <expression>

Parameters

expression The statements in between Do and Until are executed until the expression is true.

Remarks

Do...Until statements may be nested.

The expression is tested after the loop is executed, so the loop will be executed one or more times.

For...Next

--------------------------------------------------------------------------------

Loop based on an expression.

For <variable> = <start> To <stop> [step <stepval>]

statements

...

Next

Parameters

variable The variable used for the count.

start The initial numeric value of the variable.

stop The final numeric value of the variable.

stepval [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1.

While...WEnd

--------------------------------------------------------------------------------

Loop based on an expression.

While <expression>

statements

...

WEnd

Parameters

expression If the expression is true the following statements up to the WEnd statement are executed. This loop continues until the expression is false.

Link to comment
Share on other sites

  • Moderators

@smoke_n an if-case isn't a loop a loop is sth like while-wend or for-next!

@pcexpert for what do you exactly use the loo? there are some loops:

- the while-loop, which repeats while it has a special value for example.

- the for-loop, which repeats until a special value for a variable has reached

- and the do-loop, which conditions are like the one from the for:

No kidding? Wow... Thanks for the lesson... next time read and try to comprehend it a bit.

I said use the If / Then in a loop!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

yes, but actually his question was

How can I let the program restart from a point when the script has finished? For example: Your program writes a document in Word and if it has finished with it it starts over, but it only repeats the commands between /1 and /1

and this is not answered with saying him he should use a if case... read more carefully the questions and answer then only -.-*. he asks for the loops and not for if cases and wen you say him he could solve it with an ifcase and a loop he couldn't know which loop and how and so on, cause he exactly asks for it...

it's the same if you ask "how could i make a gui"

and you say you could make an ifcase if the gui should created and create one.

Link to comment
Share on other sites

  • Moderators

yes, but actually his question was

and this is not answered with saying him he should use a if case... read more carefully the questions and answer then only -.-*. he asks for the loops and not for if cases and wen you say him he could solve it with an ifcase and a loop he couldn't know which loop and how and so on, cause he exactly asks for it...

it's the same if you ask "how could i make a gui"

and you say you could make an ifcase if the gui should created and create one.

Hello,

How can I let the program restart from a point when the script has finished? For example: Your program writes a document in Word and if it has finished with it it starts over, but it only repeats the commands between /1 and /1

Thanks

BUUUUUUUUUUUUUUUUT........ONLY REPEATS SOMETHING SPECIFIC!!!!!

IF SITUATION IS TRUE THEN DO SOMETHING / IN THE LOOP!!!!

If you have him just putting it in a loop (THAT HE ALREADY HAS!!), then he will REPEAT EVERYTHING!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

maybe post your script so we can show you so that um smoke doesnt have a heart attack or something :)

It's not that, and I really want to say what I think of one of the posters, but I'm trying to keep my forum etiquette in tact.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

This is the script:

Run("C:\Program Files\Microsoft Office\OFFICE11\POWERPNT.exe")

WinWaitActive("Microsoft PowerPoint - [Presentatie1]")

MouseClick("left", 61, 34)

MouseClick("left", 60, 80)

MouseClick("left", 507, 204)

MouseClick("left", 360, 222)

MouseClick("left", 353, 435)

WinWaitActive("Microsoft PowerPoint - [presentatie]")

send("{F5}")

Sleep(272000)

Send("{SPACE}")

Send("{SPACE}")

Sleep(1000)

send("{F5}")

Link to comment
Share on other sites

The codes between

WinWaitActive("Microsoft PowerPoint - [presentatie]")

and

the last

send("{F5}")

This will loop the part you want

Run("C:\Program Files\Microsoft Office\OFFICE\POWERPNT.exe")
While 1
WinWaitActive("Microsoft PowerPoint - [Presentatie1]")
MouseClick("left", 61, 34)
MouseClick("left", 60, 80)
MouseClick("left", 507, 204)
MouseClick("left", 360, 222)
MouseClick("left", 353, 435)
WinWaitActive("Microsoft PowerPoint - [Presentatie1]")
send("{F5}")
Sleep(2000)
Send("{SPACE}")
Send("{SPACE}")
Sleep(1000)
send("{F5}")
WEnd

Remember to put in a hotkey to exit the program or it will loop forever.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

BUUUUUUUUUUUUUUUUT........ONLY REPEATS SOMETHING SPECIFIC!!!!!

IF SITUATION IS TRUE THEN DO SOMETHING / IN THE LOOP!!!!

If you have him just putting it in a loop (THAT HE ALREADY HAS!!), then he will REPEAT EVERYTHING!!

lol, he has never said that he only wants to repeat sth specific... don't know where you read that... :)

he just asked for a repeat, not for repeating sth special. don't know why you should use at his script an ifcase... -.-

Link to comment
Share on other sites

lol, he has never said that he only wants to repeat sth specific... don't know where you read that...

Yep, it is pretty funny that you and PcExpert understand the same level of grammar. I also interpreted the OP to say that help was needed to construct a conditional statement on the order of an If/Then line or two.

Enjoy your - ?victory? - it has won you a special place in hearts of many forum members.

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

Link to comment
Share on other sites

  • Moderators

My ebonics must be off if he wants to repeat the entire thing?

let the program restart from a point when the script has finished

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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