Jump to content
hutralospi

Shorten repeated SEND keystrokes

Recommended Posts

hutralospi

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.

 

Share this post


Link to post
Share on other sites
TheDcoder

You might want to use Loops :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
hutralospi

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.

 

Share this post


Link to post
Share on other sites
Bilgus

Nope though you can add the End and Tab together

Send("{END}{TAB}")

Or maybe this 

Send("{END down}{TAB 50}{END up}")

Edited by Bilgus

Share this post


Link to post
Share on other sites
TheDcoder

@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 :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites
JohnOne
_CtrlSequence("{END}", "{TAB}", 5)

Func _CtrlSequence($arg1, $arg2, $count)
    Send("{CTRLDOWN}")
    For $i = 1 To $count
        Send($arg1)
        Send($arg2)
    Next
    Send("{CTRLUP}")
EndFunc

 

  • Like 1

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
hutralospi

Thanks to all those who replied....:)

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.