Johndoe92 Posted May 3, 2017 Share Posted May 3, 2017 $key=Random(1,2,1) if $key=1 then Random, count, 1, 70 send("{DOWN %count%}") Return elseif $key=2 then Random, count, 1, 70 send("{UP %count%}") Return endif I would like to send a random number of key presses up or down in a random order. I am new at Autoit and would appreciate any advice or help. I can select up or down randomly but implementing the random # keypresses for each key is where my trouble lies. Thanks in Advance for any input. Link to comment Share on other sites More sharing options...
InunoTaishou Posted May 3, 2017 Share Posted May 3, 2017 (edited) Welcome to the forums. First, the help document for the Send function has a great description on how to send a key $n amount of times. Second, you have the wrong syntax for the call to Random. Third, the call to random assigns to the left of the assignment operator (see the help file for how to use Random) Finally, Why? Why send up/down randomly. If you're trying to select some controls there are much easier/better ways. Edited May 3, 2017 by InunoTaishou Johndoe92 1 Link to comment Share on other sites More sharing options...
Floops Posted May 3, 2017 Share Posted May 3, 2017 How about this? $key = Random(1,2,1) If $key = 1 Then $count = Random(1, 70, 1) Send("{DOWN " & $count & "}") Return ElseIf $key = 2 Then $count = Random(1, 70, 1) Send("{UP " & $count & "}") Return EndIf Johndoe92 1 Link to comment Share on other sites More sharing options...
Malkey Posted May 3, 2017 Share Posted May 3, 2017 Maybe this. HotKeySet("{ESC}", "_Terminate") ; Press Esc to exit. While Sleep(Random(100, 1000, 10)) ; Random time intervals Send("{" & (Random(0, 1, 1) ? "UP " : "DOWN ") & Random(1, 70, 1) & "}") ; Random direction up or down, and, random number of times of ups or downs sent. WEnd Func _Terminate() Exit EndFunc ;==>_Terminate Johndoe92 1 Link to comment Share on other sites More sharing options...
Johndoe92 Posted May 4, 2017 Author Share Posted May 4, 2017 Thanks All I appreciate the input! Need to practice scripting more lol first attempt at autoit.. 20 hours ago, InunoTaishou said: Welcome to the forums. First, the help document for the Send function has a great description on how to send a key $n amount of times. Second, you have the wrong syntax for the call to Random. Third, the call to random assigns to the left of the assignment operator (see the help file for how to use Random) Finally, Why? Why send up/down randomly. If you're trying to select some controls there are much easier/better ways. The reason for this program i'll admit is more of an educational tool for me to see how certain things need to placed i.e. wrong syntaxes and what-not , however, I am using this script as part of a macro that opens a desktop radio player auto logs on autoselect station. Then this script will randomly select a station from a list. Link to comment Share on other sites More sharing options...
Johndoe92 Posted May 4, 2017 Author Share Posted May 4, 2017 20 hours ago, Malkey said: Maybe this. HotKeySet("{ESC}", "_Terminate") ; Press Esc to exit. While Sleep(Random(100, 1000, 10)) ; Random time intervals Send("{" & (Random(0, 1, 1) ? "UP " : "DOWN ") & Random(1, 70, 1) & "}") ; Random direction up or down, and, random number of times of ups or downs sent. WEnd Func _Terminate() Exit EndFunc ;==>_Terminate I went with your script, I like the random time intervals i can tailor this to my needs, and thanks for inputting the esc route, I wouldn't have and would've had a small annoyance LOL! Much Appreciated. 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