adm1 Posted December 31, 2005 Share Posted December 31, 2005 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! Link to comment Share on other sites More sharing options...
huldu Posted December 31, 2005 Share Posted December 31, 2005 I guess something like this might work:$var = random(5000, 50000, 1)While 1Send("{space}")Sleep($var)WEndrandom(<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 More sharing options...
MSLx Fanboy Posted January 1, 2006 Share Posted January 1, 2006 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()) Link to comment Share on other sites More sharing options...
PopSmith Posted January 1, 2006 Share Posted January 1, 2006 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 More sharing options...
Moderators SmOke_N Posted January 1, 2006 Moderators Share Posted January 1, 2006 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 More sharing options...
PopSmith Posted January 1, 2006 Share Posted January 1, 2006 (edited) Thanks SmOke_N I will try this and report back. 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 Edited January 1, 2006 by PopSmith Link to comment Share on other sites More sharing options...
BigDod Posted January 2, 2006 Share Posted January 2, 2006 Thanks SmOke_N I will try this and report back. 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 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 More sharing options...
MSLx Fanboy Posted January 2, 2006 Share Posted January 2, 2006 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()) Link to comment Share on other sites More sharing options...
PopSmith Posted January 2, 2006 Share Posted January 2, 2006 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. 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