Sign in to follow this  
Followers 0
ItsR

Random Keypress help

3 posts in this topic

Hi everyone great forum you have here, I'm having a bit a trouble though what I want autoit to do is send a random keypress out of like 4 selected keys so for example: space, w, s, d, a and it would randomly pick one

Would the code be someting like this:

Send((Random({"w" "s" "d" "a"})))

or am I completely off here? sorry if its completely wrong still learning ;) any help would be appreciated

Share this post


Link to post
Share on other sites



Wow, those look a lot like movement keys (wasd)

but assuming they are not and it was just a poor example...

$key=Random(1,5,1)

if $key=1 then

send("w")

elseif $key=2 then

send("a")

elseif $key=3 then

send("s")

elseif $key=4 then

send("d")

elseif $key=5 then

send("{SPACE}")

endif

that will only run once, to make it run more than that it needs to go into a function being called from the main script when needed, or put in a loop

Also you could use switch...case instead of if...esleif


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Thanks that's exactly what I need.

Thankyou very much for your help ;)

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