Double (R+L) mouse buttons to toggle between two sends Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ARkaine
Posts: 20
Joined: 30 Dec 2019, 07:58

Double (R+L) mouse buttons to toggle between two sends

Post by ARkaine » 07 Jun 2023, 23:39

ATM I have such script (based on: viewtopic.php?t=23270),

Code: Select all

RButton & LButton::
Toggle := !Toggle
If (Toggle)
	Send p
Else
	Send i
Return
But the problem is that LButton makes double click, so sometimes it send "pi" or "pi".

Can something like "block"/sleep of next LButton pressing (or maybe overall) be inserted before/after "p" (or maybe for whole script)?

Dunno, sometimg like:

Code: Select all

RButton & LButton::
Toggle := !Toggle
If (Toggle)
	Send p
	Sleep, 125
Else
	Send i
Return
or

Code: Select all

RButton & LButton::
Toggle := !Toggle
If (Toggle)
	Send p
	LButton::Return
Else
	Send i
Return
Please help.

Rohwedder
Posts: 7614
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Double (R+L) mouse buttons to toggle between two sends  Topic is solved

Post by Rohwedder » 08 Jun 2023, 00:56

Hallo,
Can something like "block"/sleep of next LButton pressing (or maybe overall) be inserted before/after "p" (or maybe for whole script)?
Each of these would be feasible each with different implications. The simplest of these is:

Code: Select all

RButton & LButton::
Toggle := !Toggle
If (Toggle)
	Send p
Else
	Send i
Sleep, 125
Return
Alternatively, deactivate at a time of 200 ms this Hotkey:

Code: Select all

RButton & LButton::
Hotkey, RButton & LButton, Off
SetTimer, HOn, -200 
If (Toggle := !Toggle)
	Send p
Else Send i
Return
HOn:
Hotkey, RButton & LButton, On
Return
or suspend the script:

Code: Select all

RButton & LButton::
Suspend, On
SetTimer, SOff, -200 
If (Toggle := !Toggle)
	Send p
Else Send i
Return
SOff:
Suspend, Off
Return

ARkaine
Posts: 20
Joined: 30 Dec 2019, 07:58

Re: Double (R+L) mouse buttons to toggle between two sends

Post by ARkaine » 08 Jun 2023, 03:32

Rohwedder,

Seems that first one works perfectly, thanks. :)

The "problem" of 2nd and 3rd is that both this scripts make
LButton (especially: send i) with holding RButton unworking.

It makes

RButton & LButton (pressed first time) send p
RButton & LButton (pressed second time) send i

^ Now I see, that "stop all" was bad idea.

Post Reply

Return to “Ask for Help (v1)”