Jump to content

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

Setting up a toggle to spam one key


  • Please log in to reply
3 replies to this topic
RhaegarG
  • Members
  • 1 posts
  • Last active: Jul 03 2013 06:23 AM
  • Joined: 03 Jul 2013

Hi, I'm new to autohotkey and was looking for a possible solution with a script I've been running. Currently it's the hold down button 1-9 and it spams the key with 500ms delay. (so it is harder to detect within the game) I am looking to set it up so I can press the 1 button one time and it will continue spamming 1 every 500ms until I press it again. Is this possible with AHK?

 

Script attached below:

 

Spoiler


MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009

I suppose there should be an answer somewhere in this topic:

http://www.autohotke...utofire-thread/


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio Fran├ža -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

This is one way it could be done...

1::
2::
3::
4::
5::
6::
7::
8::
9::
Suspend, On
x := A_ThisHotkey
keywait %x%
While (1)
{   Send, %x%
    kw := (A_Tickcount + 500)
    While (A_Tickcount < kw)
    {   If (GetKeyState(x,"P"))
        {   MsgBox,0,, %x% stopped,1
            Break 2
        }
    }
}
Suspend, Off
Return

Esc::
Suspend, Permit
ExitApp

This was tested with notepad and works. I will not guarantee it will work in any specific game without further testing.


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


Rijul Ahuja
  • Members
  • 763 posts
  • Last active: Nov 25 2013 10:16 AM
  • Joined: 14 Mar 2012
Loop, 9
    Hotkey, % A_Index, HotkeyLabel
return

HotkeyLabel:
ToSend:=A_ThisHotkey
SetTimer, SpamLabel, % (Toggle:=!Toggle) ? "500" : "Off"
return

SpamLabel:
Send % ToSend
return

It will only work with one key spamming at a time, that is, if you are spamming 1 right now, you must turn it off manually before starting to spam 2.


Abandon the forum. The community has decided in a democratic vote to leave this website because of inactive and perverse administration.

Very few of the contributing members remain here.