0

I am using the LButton (mouse left) in a keybind as a prefix key. I got it to work, problem is I now need to redefine the LButton as whatever it was in it's natural state...in Autohotkey's terms.
I read this: https://www.autohotkey.com/docs/commands/GetKeyState.htm.
And cameup with the following code, but it's not working at all the way I thought it would. Simply put, you can use $LButton::Send {Click Left} to emulate the basic mouse click. The problem is when you hold the button/key down, nothing happens. I thought the code to emulate, or define the 'pressed down' behaviour would be readily available, but what I've found isn't working.

$LButton::
    if (GetKeyState("LButton", "P"))  
        Send, {Click Left Down} ;tried variants with {Click Left} etc alrdy
    else
        Send, {Click Left Up}

return

For person in comments:

LButton & ~RButton::
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return

$LButton:: ;no idea what this shud be
SendInput {Click Left}
;Send, {Click Left Down}
;KeyWait, LButton   
;Send, {Click Left Up}
return

RButton::
Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return
2
  • This is the wrong approach, can you show the hotkey you have which uses LButton so I can recommend a better approach for that case? Commented Sep 21, 2020 at 23:12
  • posted to the post Commented Sep 21, 2020 at 23:28

3 Answers 3

0

Not sure if I understood this correctly, but you want holding LButton, then clicking the RButton to run this code:

Send, 1{Click Right}{Click Left}{Click Right}{MButton}
Sleep 130 ;125
Send, 1

And just clicking RButton should run that code as well?
And if LButton is just pressed normally (not in combination with RButton) it should function as normal?

Well this would be it:

~LButton & RButton::
RButton::
    Send, 1{Click Right}{Click Left}{Click Right}{MButton}
    Sleep, 130
    Send, 1
return

Basically just making use of the ~ modifier.

Although I can't speak for Send, 1{Click Right}{Click Left}{Click Right}{MButton}.
I don't know what it's supposed to do, but maybe/hopefully it's doing the right thing.

Sign up to request clarification or add additional context in comments.

3 Comments

this code generates error messages. RButton:: on its own will set the key to nothing/null. Sends nothing and return is implied. I've not seen any syntax to date that allows u to put a hotkey within a hotkey that will ignore the above.
Stacking labels is normal AHK syntax. There are no errors in that code. Though now that you made me think about it, the first hotkey is totally redundant, RButton gets clicked anyway, lol. What errors are you supposedly getting?
my mistake, seems to work as desired when testing sending keys to notepad. isn't working ingame tho. is there a way to maybe freeze the lbutton's functionality at the time of ignition? would need a 600ms freeze or so to get through rbutton's cmds
0

Pressing w or something that you define should do the job

w::
Send, {Click down}
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return

Anyone looking for something similar could try in this direction

Comments

0
#SingleInstance force
#warn

r::Reload
x::ExitApp
w::
Send, {Click down}
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
return

just Pressing w should do the job

Alternately

, the below one will do the same

LButton::Send, {Click down}

RButton::
if GetKeyState("LButton", "P")
{
Send, {Blind}1{Click Right}{Click}{Click Right}{MButton}
Sleep 130 ;125
Send, 1
}
else
Send, {Click Right}
return

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.