XcKyle93 Posted July 28, 2013 Share Posted July 28, 2013 Hello, I am new to AutoIt, and this is my first post on these forums. I just have a brief question regarding the Send() function, and how I use it in my code. The task that I am trying to automate requires a long sequence of keystrokes, one right after the other. I could just put all of the keystrokes into one string, and pass that to the Send() function. However, I've decided to break my one Send() call up into many smaller Send() calls instead, one right after the other. Why do I do this? For readability and understanding. Otherwise, I just have one giant line with a Send() call that is very hard to dissect/understand, even with comments. My question, however, is the following: would this make my program noticeably less efficient? I don't know how much overhead is involved in calling Send(), much less any function in AutoIt, but is it enough to make a difference after a myriad of Send() calls? An excerpt from my program is below (this part is in a loop actually): Send("{ALT}m") ; Access Music Tools -> Options menu Send("e") ; Select end point of video Send("^c") ; Copy time Send("{ESC}") ; Exit text box Send("{ALT}v") ; Select Video Tools -> Edit Send("d") ; Select duration of video Send("^v") ; Paste time Send("{BS}{ENTER}") ; remove "s" so time is purely numerical Also, a bit unrelated to the topic at hand, but is there much of a difference between using, say, ^ vs. {CTRL} for the CTRL key? I know that, for example, this allows for easier repition, e.g. {CTRL 4}, but is there any difference in delay per keystroke between Send("{CTRL}c") and Send("^c")? Thanks, Kyle Link to comment Share on other sites More sharing options...
FireFox Posted July 29, 2013 Share Posted July 29, 2013 Hi,Welcome to the autoit forum There is no real code efficiency difference by using the Send function multiple times instead of one time.You can check it with this simple script :Local $hTimer = TimerInit() Send("{ALT}m" & _ "e" & _ "^c" & _ "{ESC}" & _ "{ALT}v" & _ "d" & _ "^v" & _ "{BS}{ENTER}") ConsoleWrite(Round(TimerDiff($hTimer) / 1000, 4) & " secs" & @CrLf) $hTimer = TimerInit() Send("{ALT}m") Send("e") Send("^c") Send("{ESC}") Send("{ALT}v") Send("d") Send("^v") Send("{BS}{ENTER}") ConsoleWrite(Round(TimerDiff($hTimer) / 1000, 4) & " secs" & @CrLf)Also, a bit unrelated to the topic at hand, but is there much of a difference between using, say, ^ vs. {CTRL} for the CTRL key? I know that, for example, this allows for easier repition, e.g. {CTRL 4}, but is there any difference in delay per keystroke between Send("{CTRL}c") and Send("^c")?The {CTRL} key macro does not exists, it's whether {LCTRL} or {RCTRL}.^ is used for key combination, it will be pressed until the other keys are sent, wherease the macros listed above will only send the ctrl key.Br, FireFox. Link to comment Share on other sites More sharing options...
czardas Posted July 29, 2013 Share Posted July 29, 2013 Each of the commands you are sending need to be completed before each subsequent call to the Send function. If it was only text being sent then you could possibly make your code more compact by sending all the text in one hit. Readabiliy and consistancy are also important: if dividing the text into chunks makes it easier to understand then do that instead. operator64 ArrayWorkshop 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