Need some help with key pressing please!

Ask gaming related questions (AHK v1.1 and older)
n0nam3333
Posts: 3
Joined: 29 Jul 2021, 17:13

Need some help with key pressing please!

21 May 2024, 07:06

Hey there and sorry asking for this, I'm really new to this.

Can someone help me or share me a really easy script that will help me with button smashing.

What I'm using atm is something like this that i found online -

Code: Select all

~1::
loop
{
  GetKeyState, ScrollLockState, ScrollLock, T
 
  if (ScrollLockState = "U") {
    break
  } else {
    Send 1
    Sleep, 10 ; Sleep for 20 msec
    GetKeyState, state, 1, P
    if state = U  ; The key has been released, so break out of the loop.
      break
  }
}
return
The problems is that i'm using some key combiantion like ALT+1, ALT+2+3+4 and also SHIFT+1,2,3,4. Is there something i can do to make them work with the script above?
I'm really new to this so i don't understand much and I'm sorry.

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
User avatar
mikeyww
Posts: 27261
Joined: 09 Sep 2014, 18:38

Re: Need some help with key pressing please!

21 May 2024, 07:41

Welcome to this AutoHotkey forum!

Whether a script works depends on what you want the script to do. I suggest that you provide a description of that.

If you are new to AHK, I recommend using its current version, which is v2, instead of this older deprecated version that is no longer developed.

Code: Select all

#Requires AutoHotkey v1.1.33.11

#If GetKeyState("ScrollLock", "T")
*1::
SetKeyDelay 20, 25
While GetKeyState("ScrollLock", "T") & GetKeyState("1", "P")
 SendEvent 1
Return
#If
Explained: Wildcard
n0nam3333
Posts: 3
Joined: 29 Jul 2021, 17:13

Re: Need some help with key pressing please!

21 May 2024, 08:32

I want the script to do when i press 1 to keep pressing 1 till I release the button. I manage to make that work but i can't make it work for key combiantion like alt+1,2,3 etc or Shift+1.2.3, when i press alt the script doesn't work anymore. Like if i hold ALT+1 the script will not press the combination.
User avatar
mikeyww
Posts: 27261
Joined: 09 Sep 2014, 18:38

Re: Need some help with key pressing please!

21 May 2024, 08:55

You can try blind mode with your Send.

Code: Select all

SendEvent {Blind}1
Ensure that you are using the wildcard hotkey modifier as shown.
n0nam3333
Posts: 3
Joined: 29 Jul 2021, 17:13

Re: Need some help with key pressing please!

21 May 2024, 14:21

Can you please make me an example using alt+1 or 2 or 3, so I can copy paste and edit over that, as i mention above im new to this and have no clue what to do.

To clarify:

1.) I press and hold 2, AHK spams 222222222
2.) While continuing to hold 2, I hold Alt, intending to spam alt-2 for the duration, but AHK just continues to spam 2
User avatar
mikeyww
Posts: 27261
Joined: 09 Sep 2014, 18:38

Re: Need some help with key pressing please!

21 May 2024, 15:20

Test in Notepad to see how it works. Use this script with no other code and no other scripts running.

Code: Select all

#Requires AutoHotkey v1.1.33.11

*2::
SetKeyDelay 25, 25
While GetKeyState("2", "P")
 SendEvent {Blind}2
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 46 guests