Page 1 of 1

looking to slightly modify a script

Posted: 27 Sep 2021, 18:07
by mdrake1
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

Re: looking to slightly modify a script

Posted: 27 Sep 2021, 19:03
by mikeyww

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

Re: looking to slightly modify a script

Posted: 27 Sep 2021, 19:24
by mdrake1
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

Re: looking to slightly modify a script

Posted: 27 Sep 2021, 19:36
by mikeyww
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

Re: looking to slightly modify a script

Posted: 27 Sep 2021, 19:54
by mdrake1
It works perfectly now, thanks so much.