Sign in to follow this  
Followers 0
cereberusv

Key Sequence in a loop...

6 posts in this topic

Could somebody help me to make something that presses an arrow key, followed by enter, as well as a pause before repeating?

I'm new to this and I am not very sure of all the commands...

Thanks =]

Share this post


Link to post
Share on other sites



Could somebody help me to make something that presses an arrow key, followed by enter, as well as a pause before repeating?

I'm new to this and I am not very sure of all the commands...

Thanks =]

Welcome to the forums :)

To make a key press look up Send in the help. The way to send the enter key is listed with the other key codes.

To pause look up Sleep.

To repeat you can use While and wend. All these things are in the help with examples, so you can try them out.

Good luck.


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.

Share this post


Link to post
Share on other sites

Put the following into a loop. Remember to add a method to exit the loop

Send("{RIGHT} {ENTER}");; Send the arrow right key followed by enter
Sleep (2000);; Sleep for 2 seconds

The following will perform the operation 3 times in a loop

For $i = 1 To 3
   Send("{RIGHT} {ENTER}");; Send the arrow right key followed by enter
   Sleep (2000);; Sleep for 2 seconds
Next

You might have to play with

Opt ("SendKeyDelay")

value (see help) to get it working properly.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you, both of you, for your help, also i tried setting it to a hotkey like this

For $i = 1 To 3
 HotKeySet ("-" [, "Send("{RIGHT} {ENTER}")"] )
   Sleep (2000);; Sleep for 2 seconds
Next

but that did not work, i get an error, would anybody know why that is?

Edited by cereberusv

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thank you, both of you, for your help, also i tried setting it to a hotkey like this

For $i = 1 To 3
 HotKeySet ("-" [, "Send("{RIGHT} {ENTER}")"] )
   Sleep (2000);; Sleep for 2 seconds
Next

but that did not work, i get an error, would anybody know why that is?

No doubt in my mind that you got an error. You can not use HotKeySet that way.

HotKeySet("-", "MyFunc")
HotKeySet("{ESC}", "Quit")
While 1
   Sleep (20)
Wend
Func MyFunc()
   For $i = 1 To 3
      Send("{RIGHT} {ENTER}");; Send the arrow right key followed by enter
      Sleep (2000);; Sleep for 2 seconds
   Next
EndFunc
Func Quit()
   Exit
EndFunc

Edit: in the code above you can remove "For $i = 1 To 3" and "Next" so that it will only send the keys once each time you press "-"

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Very helpful,

Thx GEOSoft =]

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
Sign in to follow this  
Followers 0