hutralospi Posted March 19, 2018 Share Posted March 19, 2018 I have some repeated code like this: =========== Send("{CTRLDOWN}") Send("{END}") Send("{TAB}") Send("{END}") Send("{TAB}") Send("{END}") Send("{TAB}") Send("{END}") Send("{TAB}") Send("{END}") Send("{TAB}") Send("{CTRLUP}") =========== where END and TAB repeat themselves. Although the above works well, it probably is not the most efficient way to write, especially if the pattern repeats for about 50 times. How can I make it shorter, please? That is, how do I incorporate // Send("+{TAB 4}") ; Presses Shift + Tab 4 times // here, because it involves two keys END and TAB ? Thanks. Link to comment Share on other sites More sharing options...
TheDcoder Posted March 19, 2018 Share Posted March 19, 2018 You might want to use Loops EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
hutralospi Posted March 19, 2018 Author Share Posted March 19, 2018 Thanks for the quick reply. Yes, the following code nicely replaces the earlier one : =========== Send("{CTRLDOWN}") For $i = 1 To 5 Step 1 Send("{END}") Send("{TAB}") Next Send("{CTRLUP}") =========== However, I was hopeful of a single line of code like Send(("{END}" "{TAB}") 5) . Anyway, if not possible, leave it, not much an issue. Thanks. Link to comment Share on other sites More sharing options...
Bilgus Posted March 19, 2018 Share Posted March 19, 2018 (edited) Nope though you can add the End and Tab together Send("{END}{TAB}") Or maybe this Send("{END down}{TAB 50}{END up}") Edited March 19, 2018 by Bilgus Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2018 Share Posted March 19, 2018 Create a function. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
TheDcoder Posted March 19, 2018 Share Posted March 19, 2018 @hutralospi There is no way to do something like that with Send unfortunately. Using a For loop is the best we can do. P.S The Step keyword in a For loop is optional and is 1 by default EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
JohnOne Posted March 19, 2018 Share Posted March 19, 2018 _CtrlSequence("{END}", "{TAB}", 5) Func _CtrlSequence($arg1, $arg2, $count) Send("{CTRLDOWN}") For $i = 1 To $count Send($arg1) Send($arg2) Next Send("{CTRLUP}") EndFunc Bilgus 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
hutralospi Posted March 19, 2018 Author Share Posted March 19, 2018 Thanks to all those who replied.... 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