looking to slightly modify a script

Ask gaming related questions (AHK v1.1 and older)
mdrake1
Posts: 29
Joined: 18 Oct 2020, 07:15

looking to slightly modify a script

Post by mdrake1 » 27 Sep 2021, 18:07

This is the script that some here was nice enough to make for me. I'd like to modify it slightly. So currently when i hold left mouse, after 0.3 sec it will hit the number 1 one time. What i want is when i hold left button for 0.3 sec it will still hit numer 1 but it will hold it untill i release left mouse button.

Code: Select all

LButton::
KeyWait, %A_ThisHotkey%, T.3
Send % ErrorLevel ? "1" : "{LButton}"
Return

User avatar
mikeyww
Posts: 27086
Joined: 09 Sep 2014, 18:38

Re: looking to slightly modify a script

Post by mikeyww » 27 Sep 2021, 19:03

Code: Select all

LButton::
KeyWait, %A_ThisHotkey%, T.3
If ErrorLevel { ; Held
 Send {1 down}
 SoundBeep, 1500
 KeyWait, %A_ThisHotkey%
 Send {1 up}
 SoundBeep, 1000
} Else Click
Return

mdrake1
Posts: 29
Joined: 18 Oct 2020, 07:15

Re: looking to slightly modify a script

Post by mdrake1 » 27 Sep 2021, 19:24

mikeyww wrote:
27 Sep 2021, 19:03

Code: Select all

LButton::
KeyWait, %A_ThisHotkey%, T.3
If ErrorLevel { ; Held
 Send {1 down}
 SoundBeep, 1500
 KeyWait, %A_ThisHotkey%
 Send {1 up}
 SoundBeep, 1000
} Else Click
Return
Ok so when i try this it's still hitting the 1 key only one time in notepad, i'm looking for it to hold down 1 constantly untill i release left button.
Could it be this that i found.Keyboard keys have a native key repeat, so holding a button down and releasing it results in the events: down-down-down-down-up; repeatedly triggering the hotkey. Mouse button don't have that, so you need to mimic it

User avatar
mikeyww
Posts: 27086
Joined: 09 Sep 2014, 18:38

Re: looking to slightly modify a script

Post by mikeyww » 27 Sep 2021, 19:36

That's what it does-- holds the key-- but it doesn't act exactly the same as your keyboard-- as you have noted in your post. The following will send the key repeatedly.

Code: Select all

LButton::
KeyWait, %A_ThisHotkey%, T.3
If ErrorLevel ; Held
 While GetKeyState(A_ThisHotkey, "P") {
  Send 1
  Sleep, 15
 }
Else Click
Return

mdrake1
Posts: 29
Joined: 18 Oct 2020, 07:15

Re: looking to slightly modify a script

Post by mdrake1 » 27 Sep 2021, 19:54

It works perfectly now, thanks so much.

Post Reply

Return to “Gaming Help (v1)”