Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

How to randomize delays between keystrokes in hotstring


  • Please log in to reply
13 replies to this topic
Bernard
  • Guests
  • Last active:
  • Joined: --
I'd like to write a small script with common chat abbreviations like IMHO, BTW and so on. The problem is that the chat seems to implement some methods to detect such tricks (defending itself from bots).

It probably measures the time between keystrokes, maybe some other technics as well.

Thanks,
Bernard

BoBo
  • Guests
  • Last active:
  • Joined: --
With Random?

Bernard
  • Guests
  • Last active:
  • Joined: --

With Random?


So far it looks like that.

#Hotstring sp k100
::BTW::By The Way
::IMHO::In My Humble Opinion

Won't these sentences be replayed with the same speed even if I repalace "k100" with a expression producing random number ?

Sorry for lame questions but I've been using AHK for an hour only.

BoBo
  • Guests
  • Last active:
  • Joined: --

Hotkey
--------------------------------------------------------------------------------
Creates, modifies, enables, or disables a hotkey while the script is running.

Hotkey, KeyName [, Label, Options]
Hotkey, IfWinActive/Exist [, WinTitle, WinText]

Show me where you've taken from the above HotKey syntax that you've to set a KeyDelay that way!

Bernard
  • Guests
  • Last active:
  • Joined: --

Hotkey


I meant hotstring not hotkey

BoBo
  • Guests
  • Last active:
  • Joined: --

I meant hotstring not hotkey

OK.
Show me where you've taken from the existing HotString syntax that you've to set a KeyDelay that way!

BoBo
  • Guests
  • Last active:
  • Joined: --

Kn: Key-delay: This rarely-used option sets the delay between keystrokes produced by auto-backspacing or auto-replacement. Specify the new delay for n; for example, specify k10 to have a 10ms delay and k-1 to have no delay. The exact behavior of this option depends on which sending mode is in effect:

Holy Moly :shock:. My appologize :oops:. I've definitley haven't used that ever before and therefore wasn't aware of it. :roll:

Yes, I guess you're right. The kparam delay will work as a generic/default setting for all Hotkeys.

BoBo
  • Guests
  • Last active:
  • Joined: --
Please have a look if that helps:

SI or SP or SE [v1.0.43+]: Sets the method by which auto-replace hotstrings send their keystrokes. These options are mutually exclusive: only one can be in effect at a time. The following describes each option:

SI stands for SendInput, which became the default in v1.0.43+ because of its superior speed and reliability. Another benefit is that like SendPlay below, SendInput postpones anything you type during a hotstring's auto-replacement text. This prevents your keystrokes from being interspersed with those of the replacement. When SendInput is unavailable, hotstrings automatically use SendPlay instead.
SP stands for SendPlay, which may allow hotstrings to work in a broader variety of games.
SE stands for SendEvent, which is the default in versions older than 1.0.43.



Bernard
  • Guests
  • Last active:
  • Joined: --
Ok, but I need a script which can transform "btw{space}" to "{3xbackspace}by the way" and will send keystrokes in undeterministic way not with one delay eg. 100ms; but 100ms +/- 10ms (93, 104, 99, 102...) or 1000ms +/- 200ms. that's the only way to be not banned form chatroom every time I want to use it. I hope you understand what I mean.

BoBo
  • Guests
  • Last active:
  • Joined: --
::BTW::

	SendToChat("By The Way")

	Return

  

::IMHO::

	SendToChat("In My Humble Opinion")

	Return



SendToChat(Phrase)

{

   Random, Delay, 500, 1000

   SetKeyDelay, %Delay%, 0

   SendPlay, %Phrase%

   Return

   }
Untested.

BoBo
  • Guests
  • Last active:
  • Joined: --
Erm, it adds the text instead of replacing it :roll:

tonne
  • Members
  • 1654 posts
  • Last active: May 06 2014 06:22 PM
  • Joined: 06 Jun 2006
IMHO the script would use same keydelay for every inter-character delay, but i may be wrong :roll:

This loops the Phrase and sleeps anything from 0.1 to 1 second.
SendToChat(Phrase)
{   
  loop, Parse, Phrase
  {
    send %a_loopfield%
    random, delay, 100, 1000
    sleep %delay%
  }
}


Bernard
  • Guests
  • Last active:
  • Joined: --
yes, that will do. now only one think to be sort out, relplacing instead of adding to phrase

Thanks

tonne
  • Members
  • 1654 posts
  • Last active: May 06 2014 06:22 PM
  • Joined: 06 Jun 2006
Forgot about the deletion. This enhanced function has 3 new parameters:
DeleteChar: the length of IMHO (might be an internal var for this)
Min: Lower limit for delay (default 100)
Max: Upper limit for delay (default 1000)

::IMHO::
   SendToChat("In My Humble Opinion",4,90,110)
   Return

SendToChat(Phrase, DeleteChars, min = 100, max = 1000)
{
  loop %DeleteChars%
  {
    send {BS}
    random, delay, %min%, %max%
    sleep %delay%
  }
  loop, Parse, Phrase
  {
    send %a_loopfield%
    random, delay, %min%, %max%
    sleep %delay%
  }
}