Jump to content

Recommended Posts

Posted

Hey guys, i am new at this and was wondering how you would write in the delay part to randomize the delays. Say i wanted to press space bar at random intervals. How would i do this? Thank you!

Posted

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!!!"

Posted

It might be a bit easier to read

While 1
   Send("{space}")
   Sleep(1000*random(5, 50, 1))
WEnd

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Posted

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?

  • Moderators
Posted

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.

Posted (edited)

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
Posted

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

Posted

You realize that the While 1...WEnd in the SendRandomKeys Func is probably going to produce unwanted output. Remove those two lines, and it might be more favorable

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Posted

Hi guys, if you want you can look at my script, I am not sure how to get the random keys to function (sorry, I am a newbie :"> )

I attached the .au3 of the script with some notes on what I am trying to do.

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
×
×
  • Create New...