Jump to content

Randomizing key presses


adm1
 Share

Recommended Posts

I guess something like this might work:

$var = random(5000, 50000, 1)

While 1

Send("{space}")

Sleep($var)

WEnd

random(<min value>, <highest value>, 1)

Mine would do anything between 5 seconds and 50 seconds.

"I'm paper, rock is fine, nerf scissors!!!"

Link to comment
Share on other sites

Hello

I have a question along these lines so I thought I would post in this forum. Is it possible to enter random keys from the keyboard?

Sorry if this sounds kind of vague, by this I mean I want my script to do this:

Send ("{Random Keys (at least 7, but not more then 15) pressed, highlight what was just pressed, copy to clipboard}")

Sleep (5000)

Is this possible?

Link to comment
Share on other sites

  • Moderators

SendRandomKeys()

Func SendRandomKeys()
    While 1
        Local $String
        Local $StringLen
        Local $Clip
        Local $Random = Random(7, 15, 1)
        Do
            $Chr = Random(32, 126, 1)
            $String = $String & Chr($Chr)
            $StringLen = StringLen($String)
        Until $StringLen = $Random
        $Clip = $Clip & $String & @CRLF
        ClipPut($Clip)
        Send($String)
        $String = ""
        Sleep(5000)
    WEnd
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks SmOke_N I will try this and report back.

:P It didn't work, I am getting an error

Line 0 (File "C:\Documents and Settings\ChOnG\Desktop\My Script.exe)

Func SendRandomKeys()

Error: "While" statement has no matching "Wend" statement.

Thanks for any help you can provide :lmao:

Edited by PopSmith
Link to comment
Share on other sites

Thanks SmOke_N I will try this and report back.

:P It didn't work, I am getting an error

Line 0 (File "C:\Documents and Settings\ChOnG\Desktop\My Script.exe)

Func SendRandomKeys()

Error: "While" statement has no matching "Wend" statement.

Thanks for any help you can provide :lmao:

I have made a slight mod to Smoke_N's script to add hotkeys

HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "SendRandomKeys")
While 1
    Sleep(100)
    WEnd

Func SendRandomKeys()
    While 1
        Local $String
        Local $StringLen
        Local $Clip
        Local $Random = Random(7, 15, 1)
        Do
            $Chr = Random(32, 126, 1)
            $String = $String & Chr($Chr)
            $StringLen = StringLen($String)
        Until $StringLen = $Random
        $Clip = $Clip & $String & @CRLF
        ClipPut($Clip)
        Send($String)
        $String = ""
        Sleep(5000)
    WEnd
EndFunc

Func Terminate()
    Exit 0
EndFunc

Run it in Beta, bring up notepad then hit F9 and see the results.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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...