Vacca Posted June 14, 2008 Share Posted June 14, 2008 (edited) I've written a script to save a stream using Audacity, but, when it asks for the name that the stream should be saved as and I pass it a string consisting of today's date, most of the name gets truncated. ie If I use: ControlSend("Save MP3 File As:", "", "Edit1", "20080613") the file will be saved as "20.mp3". The only way that I have managed to get it to 'sometimes' save with a longer name, is to put a sleep command right after the ControlSend command. I have no clue why this might make a difference, but sometimes it does. (Now that I try running it again, I'm always getting the truncation, with or without the sleep command) Does anybody have any idea what might be happening here? Edited June 14, 2008 by Vacca Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 I've written a script to save a stream using Audacity, but, when it asks for the name that the stream should be saved as and I pass it a string consisting of today's date, most of the name gets truncated. ie If I use: ControlSend("Save MP3 File As:", "", "Edit1", "20080613") the file will be saved as "20.mp3". The only way that I have managed to get it to 'sometimes' save with a longer name, is to put a sleep command right after the ControlSend command. I have no clue why this might make a difference, but sometimes it does. (Now that I try running it again, I'm always getting the truncation, with or without the sleep command) Does anybody have any idea what might be happening here?It might be worth trying another method like ControlCommand("Save MP3 File As:", "", "Edit1","EditPaste", "20080613") though I wouldn't expect it to be any different. You must have something in your script to delay before you send Enter I suppose. Maybe you could wait until the text is correct like this $text = "20080613" $rt = '' while $rt <> $text $rt = ControlCommand("Save MP3 File As:", "", "Edit1","GetLine",1) sleep(40) wend Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Vacca Posted June 14, 2008 Author Share Posted June 14, 2008 (edited) Thanks Martin. I'll try your suggestions. ps ok It looks like it works consistently with the second method. The only thing that worries me about that, is the possibility of an infinite loop, so I'll add a counter to stop it running away. It definitely looks like it was a timing issue. Edited June 14, 2008 by Vacca Link to comment Share on other sites More sharing options...
Vacca Posted June 14, 2008 Author Share Posted June 14, 2008 ok, I spoke too soon. Sometimes it works perfectly, and other times, nothing. Very, very strange. Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 ok, I spoke too soon. Sometimes it works perfectly, and other times, nothing. Very, very strange. ARe you using this idea? $text = "20080613" $rt = '' while $rt <> $text $rt = ControlCommand("Save MP3 File As:", "", "Edit1","GetLine",1) sleep(40) wend If so can you see that the text has been entered ciorrectly in the edit? If you have put a counter in to stop waiting forever, can you see if the counter limit has been reached and if so print out the value of $rt? Or does the script sometimes fail even though $rt is correct? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Kiti Posted June 14, 2008 Share Posted June 14, 2008 Why always at the end of a loop there is a sleep() ? Is it helpful? Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
martin Posted June 14, 2008 Share Posted June 14, 2008 Why always at the end of a loop there is a sleep() ? Is it helpful?If the script is going to check the contents of the edit continually it seems unecessary to check as fast as AUtoIt can run, so I thought a delay would reduce the 'effort' a bit. But I don't think it is affecting the problem, do you? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Vacca Posted June 15, 2008 Author Share Posted June 15, 2008 Oh man, am I ever embarrassed! I found a bug in my script that was sending an {enter} too soon and causing the timing difficulties. Removed that, and everything worked fine. Sorry chaps, but thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now