2

This script "autofires" E while holding it down.

    $e::
While GetKeyState("e","P")
{
    Random, r, 50, 250
    sleep r
    Send e
}
return

Is there a way to globally use this script for any key?

For example: Holding A, will autofire A and Z will autofire Z, etc.

Without manually assigning every possible key on the script.

3

1 Answer 1

3
$a::
$b::
$c::
$d::
$e::
$f::
$g::
$h::
$i::
$j::
$k::
$l::
$m::
$n::
$o::
$p::
$q::
$r::
$s::
$t::
$u::
$v::
$w::
$x::
$y::
$z::
StringReplace, ThisKeyLabel, A_ThisLabel, $
While GetKeyState(ThisKeyLabel,"P")
{
    Random, r, 50, 250
    sleep r
    Send % ThisKeyLabel
}
return

The code uses A_ThisLabel to determine what button is pressed. I think I can probably setup a loop and use another function to declare the trigger, but I couldn't be bothered because this works :P

Note that the StringReplace is necessary because the $ will show up in the A_ThisLabel. If you have different hotstrings, like !a or +a or whatever, you'll need to remove the stuff you don't want to Send out.

EDIT: I can't find how to create the hotkeys using a loop or anything of that sort, but I just added in all the hotkeys manually and that only took me 15 seconds.

1
  • 1
    Excelent! Thank you very much. I'mm teeeeeestiiigg it riight noooooow. Feb 24, 2015 at 1:01

Not the answer you're looking for? Browse other questions tagged .