Asking for help modifying left click toggle Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
daveyjones07
Posts: 2
Joined: 20 Oct 2021, 08:45

Asking for help modifying left click toggle

Post by daveyjones07 » 20 Oct 2021, 08:56

Hello, I've been using this left click toggle script that holds the LButton but cancels when I reuse the hotkey OR left click:
Hallo,
perhaps:
Code: Select all - Toggle Line numbers

~LButton::hold = ; switch off hold flag
!+u up:: ; TOGGLE MOUSE
if hold:= !hold ; toggle hold flag
Click down ; presses the left button
else
Click up ; releases the left button
return

or shorter:
Code: Select all - Toggle Line numbers

~LButton::hold = ; switch off hold flag
!+u up::Click,% (hold:=!hold)?"down":"up" ; TOGGLE MOUSE
I works great but I was wondering if someone could help me modify one of these to toggle BOTH left click and right click, but still cancel both when I reuse the hotkey or left click. Any help would be appreciated. Cheers!

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Asking for help modifying left click toggle

Post by mikeyww » 20 Oct 2021, 09:54

Code: Select all

~LButton::
~RButton::hold := False
!+u up::Send % (hold := !hold) ? "{LButton down}{RButton down}" : "{RButton up}{LButton up}"

daveyjones07
Posts: 2
Joined: 20 Oct 2021, 08:45

Re: Asking for help modifying left click toggle

Post by daveyjones07 » 20 Oct 2021, 11:10

mikeyww wrote:
20 Oct 2021, 09:54

Code: Select all

~LButton::
~RButton::hold := False
!+u up::Send % (hold := !hold) ? "{LButton down}{RButton down}" : "{RButton up}{LButton up}"
Thanks for this, it works but when I cancel it with a left click, my left click then clicks both the LButton and RButton at the same time until I do a right click, and then it works normally. I hope that makes sense. Is there a way to around this?

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: Asking for help modifying left click toggle  Topic is solved

Post by mikeyww » 20 Oct 2021, 11:56

Perhaps:

Code: Select all

!+u up::
If hold := !hold {
 Send {LButton down}{RButton down}
 SoundBeep, 1500
} Else Gosub, ~LButton Up
Return

#If hold
~LButton Up::
~RButton Up::
Send {LButton up}{RButton up}
Send {Esc} ; OK to delete
hold := False
SoundBeep, 1000
Return
#If

Post Reply

Return to “Ask for Help (v1)”