Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Random delay between keystrokes


  • Please log in to reply
8 replies to this topic
Zea
  • Members
  • 4 posts
  • Last active: May 06 2013 06:49 AM
  • Joined: 05 May 2013

Im looking to make keystrokes look typed. Is there a way to randomize the setkeydelay? Im an extreme noob to autohotkey, I sortta learned how to do the send and how to set the key delay from just google searching and this forum, but I cant seem to find any answers online as to how to make the text appear as if its being typed.



dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010

Can you give more details on what you are trying to do? Are you using the Send command to send keystrokes in sequence, and want there to be a random time in between strokes. Or are you wanting something different? Details are our friends. wink.png


"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

Zea
  • Members
  • 4 posts
  • Last active: May 06 2013 06:49 AM
  • Joined: 05 May 2013

Exactly that. The script is literally just sleep for a few seconds (for me to switch windows), set key delay, then send with a bunch of text. I just want each letter to be type at a random interval between like... .05 seconds and .3 seconds or so.



dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010

You can use the Send command with a function that Uses the Random command:

f1::
 {
   sendinput, A
   sleep, % ran(50, 300)
   sendinput, B
   sleep, % ran(50, 300)
   sendinput, C
   sleep, % ran(50, 300)
   sendinput, D
   sleep, % ran(50, 300)
 }
return

ran(min, max)
 {
   random, ran, min, max
   return ran
 }

This should produce a random pause between 50ms and 300ms in between each character. If you are wanting to really simulate a human typing I would suggest you increase the time. Humans just don't type that fast normally. cool.png

 

Edit:

I made the change suggested by Alpha Bravo... Sometimes I am in too much of a hurry and I make ridiculous coding errors. Usually I find and fix them in testing. shy.png


"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

I believe dmg meant for the function to look like so

ran(min, max)
 {
   random, ran, min, max
   return ran
 }


Zea
  • Members
  • 4 posts
  • Last active: May 06 2013 06:49 AM
  • Joined: 05 May 2013

I think what Im looking for isnt going to happen. I have pages I want it to type, and to do a random sleep time between each letter would take ages to do. Thanks for the help though. And on a side note, I have no idea how fast people type, I was just randomly guessing. Maybe .1-.5 then, or whatever. lol.



dmg
  • Members
  • 2395 posts
  • Last active: Nov 04 2015 06:46 AM
  • Joined: 19 Nov 2010

Thank you Alpha Bravo. shy.png

 

Yes, typing out pages of data, even with no delays, would take a bit of time. Why are you trying to simulate human typing? I have answered questions like this before but they were always about fooling a video game security system.

 

If you were wanting to input large amounts of text as fast as possible, and you did not have to worry about pretending to be human, you could just paste the content by assigning it to the clipboard and sending Ctrl-V.


"My dear Mr Gyrth, I am never more serious than when I am joking."
~Albert Campion

-----------------------------------------------------------------------------------------------
Website | Demo scripts | Blog | External contact

Zea
  • Members
  • 4 posts
  • Last active: May 06 2013 06:49 AM
  • Joined: 05 May 2013

lmao! Thanks for the clipboard tip. Been working on computers for years so I know that one. The human simulation is obviously a must for my needs. Otherwise why would I bother with a delay at all? But no, not a video game security issue.



sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
You could batch everything into one function and just send it lines of text:

Send %	sendAtRandom("I want to send this string with random delays between keystrokes.")

sendAtRandom(string) {

	Loop, parse, string
	{
		Send %	A_LoopField
		Random, t, 50, 300
		Sleep, %t%
	}

}