Continue/loop and inefficient script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Continue/loop and inefficient script

07 Dec 2020, 00:07

Code: Select all

PrintScreen::

Click, 2

Sleep, 700

Send, ^c

Sleep, 200

Send, {Enter}

Sleep, 500

SendInput, {;}

Sleep, 500

SendInput, {b}

Sleep, 500

Send, ^+!r

Sleep, 500

Send, ^v

SendInput, {_}{F}{X}

Sleep, 350

Send, {Enter}

Sleep, 500

SendInput, {p}

Sleep, 500

Send, {Tab}

Sleep, 600

Send, +{Tab}

Sleep, 600

Send, ^+!r

Sleep, 500

Send, ^c

Send, {Enter}

Sleep, 500

SendInput, {;}

Sleep, 500

SendInput, {b}

Sleep, 500

Send, ^+!r

Sleep, 500

Send, ^v

SendInput, {_}{F}{X}

Sleep, 350

Send, {Enter}

Sleep, 500

SendInput, {p}

Sleep, 500

Send, {Tab}

Sleep, 600

Send, +{Tab}

Sleep, 600

Send, ^+!r

Sleep, 500

Send, ^c

Send, {Enter}

Sleep, 500

SendInput, {;}

Sleep, 500

SendInput, {b}

Sleep, 500

Send, ^+!r

Sleep, 500

Send, ^v

SendInput, {_}{F}{X}

Sleep, 350

Send, {Enter}

Sleep, 500

SendInput, {p}

Sleep, 500

Send, {Tab}

Sleep, 600

Send, +{Tab}


return

Hello all,

I did a mock script to automate a task in Pro Tools that would require me to rename hundred of files in the timeline.

So the script posted will rename 3 files in the timeline. As mentioned earlier, I have hundreds more that need to be renamed as well. My novice background can't figure out how to continue down the timeline as oppose to copy and paste what I wrote. That would probably look like 10 pages :crazy: I'm pretty positive that the current script I have is inefficient. Thanks a bunch everyone :)
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Continue/loop and inefficient script

07 Dec 2020, 01:13

Code: Select all

PrintScreen::

Click, 2

Sleep, 700


Loop {

Send, ^c

Sleep, 200

Send, {Enter}

Sleep, 500

SendInput, {;}

Sleep, 500

SendInput, {b}

Sleep, 500

Send, ^+!r

Sleep, 500

Send, ^v

SendInput, {_}{F}{X}

Sleep, 350

Send, {Enter}

Sleep, 500

SendInput, {p}

Sleep, 500

Send, {Tab}

Sleep, 600

Send, +{Tab}

Sleep, 600

Send, ^+!r

Sleep, 200



}


return
So I figured out how to loop. :headwall:

The only thing that now that I can't figure out is how to stop the Loop. I thought once it reaches the end of the timeline it stops the Loop, but it just keeps continuing. What should I input to stop the Loop when it reaches the end of the timeline.
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Continue/loop and inefficient script

07 Dec 2020, 01:22

you need to check a condition with If and a Breakto escape from the loop
Hubert
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Continue/loop and inefficient script

07 Dec 2020, 01:42

hd0202 wrote:
07 Dec 2020, 01:22
you need to check a condition with If and a Breakto escape from the loop
Hubert
Thanks for the response!

I tried inputting break at the very end, but then it stops the loop. Could you please provide me an example?
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Continue/loop and inefficient script

07 Dec 2020, 19:47

Philharmonic wrote:
07 Dec 2020, 01:42
hd0202 wrote:
07 Dec 2020, 01:22
you need to check a condition with If and a Breakto escape from the loop
Hubert
Thanks for the response!

I tried inputting break at the very end, but then it stops the loop. Could you please provide me an example?
To be clear actually, when I input Break at the end of the script, it runs through the command, top down, but then the loop breaks. It's not running through all the files as I had hope. I'm curious if there's a way that when it reaches the end of the file on the timeline, or when the timeline ends, the Loop stops. What I ended up doing was creating a HotKey to Exit the App. Which by all means is fine, but ideally I would like to run the script unsupervised. Thanks in y'all!
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Continue/loop and inefficient script

08 Dec 2020, 00:51

according to your description, you use an unconditional Break at the end of the Loop,
but you need a conditionalBreak, a Break that is only taken when a specific condition occurs

Code: Select all

Loop {
Send, ^c
Sleep, 200
if not clipboard
    break
Send, {Enter}
; and your following code
}
In this example it occurs when there is no more text found

Hubert
Philharmonic
Posts: 50
Joined: 22 May 2017, 13:51

Re: Continue/loop and inefficient script  Topic is solved

08 Dec 2020, 03:23

hd0202 wrote:
08 Dec 2020, 00:51
according to your description, you use an unconditional Break at the end of the Loop,
but you need a conditionalBreak, a Break that is only taken when a specific condition occurs

Code: Select all

Loop {
Send, ^c
Sleep, 200
if not clipboard
    break
Send, {Enter}
; and your following code
}
In this example it occurs when there is no more text found

Hubert
Thanks for trying to help me out Hubert :D It finally worked :superhappy: Your exact script didn't quite work, but I tweaked it accordingly to the application I'm using and it's working like a charm! Thanks a bunch Hubert. I truly appreciated your time by helping me out here. I posted the script below.

Code: Select all

PrintScreen::

Click, 2

Sleep, 500

Loop {

Send, ^c

Sleep, 250

Send, {Esc}

Sleep, 250

SendInput, {;}

Sleep, 250

SendInput, {b}

Sleep, 250

Send, ^+!r

Sleep, 300

Send, ^v

SendInput, {_}{F}{X}

Sleep, 200

Send, {Enter}

Sleep, 250

SendInput, {p}

Sleep, 250

Send, {Tab}

Sleep, 150

Send, +{Tab}

Sleep, 250

Send, ^+!r

Sleep, 250

if not WinExist("ahk_class DigiDialogClass")
	
break

}
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], niCode and 173 guests