Hey guys,
I'm trying to figure this out on my own since longer than I would like to admit. Even as an ahk noob I was always able to achieve what I wanted to do but I think this time I need some help.
My goal is that while I'm holding down the LButton that the left arrow keeps sending left commands as long as LButton is pressed just like it would if I pressed left direct physically. That's pretty much all.
It's for a reaction based game which is usually played with the left and right arrow keys and I would like to play with the mouse buttons instead.
I played around with GetKeyState & KeyDown but it either only spams left/right uncontrollably in an infinite loop or only once.
This is probably quite straight forward and simple but I just can't get it to work.
I hope anyone can push me into the right direction. Thanks in advance.
Keep pressing key while mousebutton is held down
-
- Posts: 5
- Joined: 20 Aug 2018, 05:53
- Contact:
Re: Keep pressing key while mousebutton is held down
Hallo,
try:F2 toggles Remapping on/off
try:
Code: Select all
LButton::Left
F2::Suspend
-
- Posts: 5
- Joined: 20 Aug 2018, 05:53
- Contact:
Re: Keep pressing key while mousebutton is held down
Already tried that. Apparently for normal keys that's good enough but for mouse buttons it doesn't work.
It ends up just clicking once.
It ends up just clicking once.
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: Keep pressing key while mousebutton is held down
Code: Select all
LButton::
While (GetKeyState, "LButton", "P")
Send {left}
Return
Re: Keep pressing key while mousebutton is held down
can u explain in simple steps how u want the program to behave cuz
it sounds like u want to repeatedly send {Left} down+up events, while LMB is held down, but i cant be too sure:
is ambiguous.while I'm holding down the LButton that the left arrow keeps sending left commands as long as LButton is pressed just like it would if I pressed left direct physically.
it sounds like u want to repeatedly send {Left} down+up events, while LMB is held down, but i cant be too sure:
Code: Select all
LButton::SetTimer SendLeft, 10
LButton Up::SetTimer SendLeft, Off
SendLeft:
Send {Left}
return
-
- Posts: 5
- Joined: 20 Aug 2018, 05:53
- Contact:
Re: Keep pressing key while mousebutton is held down
When I use this the LButton doesn't do anything.MannyKSoSo wrote:Code: Select all
LButton:: While (GetKeyState, "LButton", "P") Send {left} Return
Maybe I wasn't as clear as I hoped. I want my remap work just like it would as if I pressed and held the arrow key physically.swagfag wrote:can u explain in simple steps how u want the program to behave cuzis ambiguous.while I'm holding down the LButton that the left arrow keeps sending left commands as long as LButton is pressed just like it would if I pressed left direct physically.
it sounds like u want to repeatedly send {Left} down+up events, while LMB is held down, but i cant be too sure:
But instead pressing/holding the arrow key I want to use the mouse buttons.
I know this explanation still isn't great neither but I think you already understood what I'm trying to do by the script you sent.
Code: Select all
LButton::SetTimer SendLeft, 10
LButton Up::SetTimer SendLeft, Off
SendLeft:
Send {Left}
return
Is there a way to improve the script to get the L/RButtons behave more like the arrow keys?
Re: Keep pressing key while mousebutton is held down
try this:
Code: Select all
*LButton::Send {Blind}{Left Down}
*LButton Up::Send {Blind}{Left Up}
-
- Posts: 5
- Joined: 20 Aug 2018, 05:53
- Contact:
Re: Keep pressing key while mousebutton is held down
This one only sends a single left arrow command no matter how long I keep LMB pressed.
Re: Keep pressing key while mousebutton is held down
Code: Select all
#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1
#InstallMouseHook
#UseHook On
Loop
{
if GetKeyState("LButton", "P")
Send {Left}
else if GetKeyState("RButton", "P")
Send {Right}
else
Sleep 20
}
Esc::ExitApp
Who is online
Users browsing this forum: No registered users and 192 guests