Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Autohotkey and Rapid fire Keyboard


  • Please log in to reply
35 replies to this topic
Fenrir
  • Guests
  • Last active:
  • Joined: --
I've used the autohotkey program for utilizing a rapid fire script before on my mouse, but what I would like to know is how would you write it to work on a keyboard rather than a mouse? For example, Ctrl being the hot key and Xbutton being the rapid fire key.

codybear
  • Members
  • 600 posts
  • Last active: Feb 09 2015 12:41 PM
  • Joined: 15 Sep 2009
*~$Ctrl::
Loop
{
SetMouseDelay 30
Send, {XButton1}
If (GetKeyState("Ctrl","P")=0)
Break
}
return

Pressing and holding Control (either one) will spam xbutton1.
Feel free to adjust the setmousedelay time as I had jsut adapted the code I have to spam the right click and left click for Red Alert3 instead of pressing 50 times to build 50 people as I have worn out a couple mouses due to Red Alert 3 and Red Alert2. haha

Fenrir
  • Guests
  • Last active:
  • Joined: --

*~$Ctrl::
Loop
{
SetMouseDelay 30
Send, {XButton1}
If (GetKeyState("Ctrl","P")=0)
Break
}
return

Pressing and holding Control (either one) will spam xbutton1.
Feel free to adjust the setmousedelay time as I had jsut adapted the code I have to spam the right click and left click for Red Alert3 instead of pressing 50 times to build 50 people as I have worn out a couple mouses due to Red Alert 3 and Red Alert2. haha


Awesome. I know it's simple code but you guys work miracles from my perspective. Though what I never understood was why would you have to write "mousedelay" when the mouse isn't even involved? lol

Thanks a ton codybear

codybear
  • Members
  • 600 posts
  • Last active: Feb 09 2015 12:41 PM
  • Joined: 15 Sep 2009

Though what I never understood was why would you have to write "mousedelay" when the mouse isn't even involved? lol

Eventhough you're using a keyboard key to spam the xbutton, the xbutton is a special mouse button, therefore the mouse delay comes into affect and not the setkeydelay. I read this somewhere in the docs earlier this week again. Not quite sure where in the docs it is located though.

Fenrir
  • Guests
  • Last active:
  • Joined: --
Okay so I've been playing with the script but a problem comes up with using the Ctrl key. I guess what's happening is when I press the ctrl key and the X key the computer sees it as an entirely different event as opposed to just pressing the X key once or twice (xbutton1 and xbutton2 events).

What I need it to do for this to work is to be able to press down and hold ctrl then the X key at the same time and then Xbutton goes into rapid fire.

I've been playing around with another script as well:

Ins::Suspend
Xbutton1::
Loop
{
Setmousedelay 30
Click
If (GetKeyState("Xbutton1","P")=0)
Break
}

I don't know if I just need to enter in another argument value in place of Xbutton1 for the computer to recognize ctrl and X key or if this issue requires a whole other script to work. I tried ctrl_X and ctrl-X but that didn't seem to work either.

Desi
  • Members
  • 162 posts
  • Last active: Apr 15 2015 09:51 AM
  • Joined: 29 Oct 2010

What I need it to do for this to work is to be able to press down and hold ctrl then the X key at the same time and then Xbutton goes into rapid fire.


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

^x::
Loop                
{
    GetKeyState, Autovar, x, P
    If Autovar = U
        Break
    Send {XButton1}
    sleep 0 ; You can change this value to get the desired rate of clicks.
} 

; The following lists the number of clicks within ten seconds per x milliseconds of sleep:
;140 = 59 clicks
;130 = 65 clicks <- average highest human speed
;120 = 65 clicks
;110 = 72 clicks
;90  = 81 clicks
;70  = 92 clicks
;60  = 107 clicks
;1   = 214 clicks
;0   = 321 clicks


  • Guests
  • Last active:
  • Joined: --
I need the exact same thing, tried the above script, not working, what do?

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010

wat do?


*$LCtrl::
Send {control down}
While GetKeyState("Lctrl","p"){
Send, {XButton1}
}
Send {control up}
return

The problem lies with "ctrl", specify which side

  • Guests
  • Last active:
  • Joined: --
Okies, yeah I am playing a game where the cheat is to hold ctrl and press x, but it doesn't add enough xp at later levels so want to hold ctrl and rapid fire the x so it continues to add xp quickly =)

  • Guests
  • Last active:
  • Joined: --
Not working =/ Now when I hold Lctrl and press x get nothing, but if rapid x manually it adds xp slower. takes like three x clicks for one xp add.

  • Guests
  • Last active:
  • Joined: --
am scripting faylur! Halp!

x79animal
  • Members
  • 1021 posts
  • Last active: May 14 2013 04:21 PM
  • Joined: 01 May 2010

Not working =/ Now when I hold Lctrl and press x get nothing, but if rapid x manually it adds xp slower. takes like three x clicks for one xp add.


thats because it sends the xbutton, and you arent supposed to press the xbutton either its just lctrl.

Ill change the script based on what you have said

LCtrl & x::
Send {control down}
While GetKeyState("Lctrl","p"){
Send, {X}
}
Send {control up}
return


  • Guests
  • Last active:
  • Joined: --
Game crashed, may be doing it too fast for game to register...sad face. Sorry I'm kinda lame.

Ok so take above script, add sleep 60, press lctrl and x, hold and auto level? Try again I will.

  • Guests
  • Last active:
  • Joined: --
Ok, so the script works, but not while I'm in game, if I'm just on my pc then it's no and it ctrl xs all day hard...but not in the game, what do?

nimda
  • Members
  • 4368 posts
  • Last active: Aug 09 2015 02:36 AM
  • Joined: 26 Dec 2010
Go on the wiki faq - click "games", read :roll: