Jump to content

Problem using ControlSend.


Recommended Posts

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 by Vacca
Link to comment
Share on other sites

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

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 by Vacca
Link to comment
Share on other sites

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

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

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

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