0
votes

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
3
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? - 0x464e
posted to the post - kite

3 Answers

0
votes

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.

0
votes

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

0
votes
#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