Jump to content

sending random key random number of times


Recommended Posts

$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

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 by InunoTaishou
Link to comment
Share on other sites

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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...