Sign in to follow this  
Followers 0
darren_burgess

winwait not working so well in this solution

5 posts in this topic

Hey folks, I am new to scripting, but have some basic programming experience. I am scripting repetitive tasks in Cakewalk pro Audio. I am trying record 55 short audio tracks in a loop. Each track is the same length. The problem is the actual process of recording takes longer and longer with each iteration of the loop, to the point where my tracks are not being deactivated. I can solve the problem with a 30 second delay, but the my script takes a long time to execute. If the delay is longer than it takes to export the data, then the script works I would like a more elegant and faster solution.

Here is my code. Note that there is a while loop and other code sections. This is just the problem code.

; export track to wave

WinWait("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

If Not WinActive("Cakewalk Pro Audio - [eartraining.wrk* - Track]","") Then WinActivate("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

WinWaitActive("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

Send("{CTRLDOWN}c{CTRLUP}{ALTDOWN}o{ALTUP}xe")

WinWait("Mixdown Audio/Export to File(s)","")

If Not WinActive("Mixdown Audio/Export to File(s)","") Then WinActivate("Mixdown Audio/Export to File(s)","")

WinWaitActive("Mixdown Audio/Export to File(s)","")

Send("{CTRLDOWN}v{CTRLUP}{ENTER}") ; copies track name to filename and starts export to wave process

sleep (30000) ; This long sleep will solve my problem, but makes total run time way to long.

; deactivate current track

WinWait("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

If Not WinActive("Cakewalk Pro Audio - [eartraining.wrk* - Track]","") Then WinActivate("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

WinWaitActive("Cakewalk Pro Audio - [eartraining.wrk* - Track]","")

Sleep (1000)

MouseMove($recordcolumn, $rowvalue,0)

MouseDown("left")

MouseUp("left")

sleep (1000)

MouseMove($solocolumn, $rowvalue,0)

MouseDown("left")

MouseUp("left")

$rowvalue=$rowvalue+$rowincrease

Share this post


Link to post
Share on other sites



One correction. The problem does not happen during recording, it happens when the script is export the recorded track to a wave file. So, the exporting process takes longer and longer, and if it exceeds the length of the sleep immediately following, the the track does not get deactivated. PLEASE SOMEONE HELP!!

Hey folks, I am new to scripting, but have some basic programming experience. I am scripting repetitive tasks in Cakewalk pro Audio. I am trying record 55 short audio tracks in a loop. Each track is the same length. The problem is the actual process of recording takes longer and longer with each iteration of the loop, to the point where my tracks are not being deactivated. I can solve the problem with a 30 second delay, but the my script takes a long time to execute. If the delay is longer than it takes to export the data, then the script works I would like a more elegant and faster solution.

Share this post


Link to post
Share on other sites

Does a window pop up when it finishes exporting? Does any different text appear on the screen anywhere? Is there any indicator to show when it is finished? Otherwise you could always use a variable for sleep if you know how much longer it takes every time and increase it every loop... thats kind of sloppy though.

Share this post


Link to post
Share on other sites

No, there is no window that pops up when it is finished exporting.

I see what you are saying that perhaps there is a change in status text somewhere in cakewalk that the script can wait for, instead of using winwait and winwaitactive. I think that what is happening is that the cakewalk window is never really inactive in the eyes of the script. So that when it gets to the end of a too-short sleep while cakewalk is exporting, it tries to deactivate the track, but is unable to do so because cakewalk is busy. Therefore, the deactivation fails.

Yes, it is messy to just increase the sleep and it is not very elegant, or reliable. I think the problem is RAM related, and that an increase in RAM and/or system performance may solve the problem. But a script solution would still be more elegant and reliable.

I will check to see if Cakewalk changes any text while exporting to wave.

QUESTION: if I do find text that changes during export, how do I get the script to check for such?

Thanks for your help.

Darren

Does a window pop up when it finishes exporting? Does any different text appear on the screen anywhere? Is there any indicator to show when it is finished? Otherwise you could always use a variable for sleep if you know how much longer it takes every time and increase it every loop... thats kind of sloppy though.

Share this post


Link to post
Share on other sites

Or maybe what I could do would be to script autoit to open some dialog window in cakewalk and then cancel it. This dialog would of course only open after the export is done. I think I would still have the same problem though - autoit would attempt the next script step and fail because cakewalk is busy. Perhaps I could have a small loop run that would repeatedly attempt to open a dialog and cancel it and the script would not move on until this was successful. Success would then be dependent on the export completeing.

What do you think?

Darren

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  
Followers 0