Can't preserve hotkeys default behavior with tilde prefix

Get help with using AutoHotkey and its commands and hotkeys
XWX
Posts: 3
Joined: 16 Mar 2019, 22:00

Can't preserve hotkeys default behavior with tilde prefix

Yesterday, 08:19

Hello, I want my script to send {k} with 20ms intervals when I hold my left mouse button down, but I also want to be able to use my left mouse button as usual.

Code: Select all

LButton::
 while GetKeyState("LButton","p"){
  Send, {k}
  Sleep, 20
 }
return
The script above works but left mouse button loses its default behavior. If I change the script to:

Code: Select all

~LButton::
 while GetKeyState("LButton","p"){
  Send, {k}
  Sleep, 20
 }
return
It doesn't work anymore and I also still can't use left mouse button.

Sorry I'm not a native speaker. Any help is appreciated.
User avatar
Scr1pter
Posts: 928
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Can't preserve hotkeys default behavior with tilde prefix

Yesterday, 08:32

Hi and welcome,

This seems to be normal.
When you press and hold the left mouse button,
key inputs don't get accepted.
(At least it has just been the case for me)

What you could do is this:

Code: Select all

$lbutton:: ; $ = Prevent hotkey from triggering itself
Send {lbutton}
while GetKeyState("lbutton", "P")
{
  Send k
  Sleep, 20
 }
return
It will only make 1 click, though, but it spams k.

Cheers!
I ignore every thread which contains the P-word :x
(Hint: It rhymes on Shython)
Please do not support cheaters!
Keyboard: Logitech G15 FE - Mice: Logitech G9 FE, G502 FE, G602 - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.29.00
XWX
Posts: 3
Joined: 16 Mar 2019, 22:00

Re: Can't preserve hotkeys default behavior with tilde prefix

Yesterday, 09:54

Thanks for the answer,
Scr1pter wrote:
Yesterday, 08:32
It will only make 1 click, though, but it spams k.
Cheers!
I want LButton to behave like how it normally would though (plus act as a hotkey at the same time indefinitely as long as its held down), is it not possible?
XWX
Posts: 3
Joined: 16 Mar 2019, 22:00

Re: Can't preserve hotkeys default behavior with tilde prefix

Yesterday, 18:36

Ok I finally came up with something that preserves LButton's default functionality:

Code: Select all

$LButton::
Send, {LButton down}
while GetKeyState("LButton","p"){
 Send, {k}
 Sleep, 20
}
KeyWait, LButton
Send, {LButton up}
return
But I'm not sure if it's the right way to do it. Didn't have much time to test but it seems to be working.

Return to “Ask For Help”

Who is online

Users browsing this forum: alonzam99, bojo5150, esp901, Flipeador, Google [Bot], paik1002, teadrinker and 41 guests