Jump to content
Sign in to follow this  
AnRios

Stop Script Inside For...Next Loop

Recommended Posts

Hi there,

 

I'm very new at scripting and I have a problem. I use these extremely simple lines to exhibit and print images from SAP. However I did not manage to find a solution to make it stop before the end, could someone help? Thanks in advance.

OBS: Since I'm using the company pc, I haven't the permission to install anything, I'm running the zip version of AutoIT.

 

For $i = 1 to 600 ; I print several images a day

WinActivate("Relatorio")
Sleep (300)
BlockInput (1) ; Block Use Input
Send("{ENTER}")
Sleep (1000)
Send("{F3}") ; This activates the hotkey from PrintKey 
Sleep (250)
MouseClickDrag ( "left" ,353 ,197 ,672 ,437 ,0 )
Sleep (400)
BlockInput (0) ; Unblock Use Input
WinActivate("Relatorio")
Send("{DOWN}")

Next

Share this post


Link to post
Share on other sites

@AnRios

Set an HotKey to exit from your script, or set a boolean variable to run conditionally your script.

In any case, you can use HotKeySet() function :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Francesco, thanks for the response.

I have no idea where to insert this, before or after or between the For... Next loop. Could you give me an example?

Share this post


Link to post
Share on other sites

@AnRios

If you see in the example provided by the Help file about HotKeySet(), you'll see that the fuction is set before all the functions (in most cases), so, put it before the For...Next loop in your script :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

It's not meant to break the script. It's meant to send your keys more reliably. Send() only works on the active window. It is better coding practice. 

HotKetSet() with a exit function will break the loop. 

HotKeySet("{ESC}", "Terminate")

Func Terminate()
    Exit 0
EndFunc

 

 

Edited by SkysLastChance

Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites

@AnRios

You're welcome :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...