how to make middle mouse button alternate between inputing three times and once per click
- Theleifblower
- Posts: 12
- Joined: 16 May 2024, 16:12
how to make middle mouse button alternate between inputing three times and once per click
"MouseClick WhichButton, X, Y, ClickCount, Speed, DownOrUp, Relative"
i see that i can use this for the actual clicking part (potentially)
mouseclick "mbutton,,,3"
mouseclick "mbutton"
these would be the two outputs i want to alternate assuming i got the format right
with the hotkey also being the middle mouse button
*mbutton::
as for the logic behind switching the outputs each time the hotkey is pressed im very unsure and could use help. some parts of what i already have may also be wrong
i see that i can use this for the actual clicking part (potentially)
mouseclick "mbutton,,,3"
mouseclick "mbutton"
these would be the two outputs i want to alternate assuming i got the format right
with the hotkey also being the middle mouse button
*mbutton::
as for the logic behind switching the outputs each time the hotkey is pressed im very unsure and could use help. some parts of what i already have may also be wrong
- Noitalommi_2
- Posts: 321
- Joined: 16 Aug 2023, 10:58
Re: how to make middle mouse button alternate between inputing three times and once per click
Hi.
Please try this.
Edit: Different approach but same result.
Please try this.
Code: Select all
#Requires AutoHotkey 2.0
#SingleInstance
SendMode "Event"
SetMouseDelay 100 ; delay after each click in ms
*MButton:: {
static toggle := 1
if toggle := !toggle
Click
else Click(,, 3)
}
Code: Select all
#Requires AutoHotkey 2.0
#SingleInstance
*MButton:: {
static toggle := 1
, Delay := 100
if toggle := !toggle {
Send("{LButton down}"), Sleep(Delay), Send("{LButton up}")
}
else {
Loop 3
Send("{LButton down}"), Sleep(Delay), Send("{LButton up}")
}
}
Re: how to make middle mouse button alternate between inputing three times and once per click
After reading your post I will recommend you to use this method if it work like
"mouseclick" with "mbutton" triggers a middle mouse click.
Toggle click behavior:
Use a variable (ClickType) to store "normal" or "alternative" click.
In your hotkey script:
Perform the click based on ClickType.
Toggle ClickType after each click (e.g., ClickType := ClickType == "normal" ? "alternative" : "normal").
Alternative click example:
Define your alternative action (e.g., send a keystroke).
In the hotkey script, if ClickType is "alternative", send the defined action instead of a click.
"mouseclick" with "mbutton" triggers a middle mouse click.
Toggle click behavior:
Use a variable (ClickType) to store "normal" or "alternative" click.
In your hotkey script:
Perform the click based on ClickType.
Toggle ClickType after each click (e.g., ClickType := ClickType == "normal" ? "alternative" : "normal").
Alternative click example:
Define your alternative action (e.g., send a keystroke).
In the hotkey script, if ClickType is "alternative", send the defined action instead of a click.
- Theleifblower
- Posts: 12
- Joined: 16 May 2024, 16:12
Re: how to make middle mouse button alternate between inputing three times and once per click
Noitalommi_2 wrote: ↑16 May 2024, 21:49Hi.
Please try this.
Edit: Different approach but same result.Code: Select all
#Requires AutoHotkey 2.0 #SingleInstance SendMode "Event" SetMouseDelay 100 ; delay after each click in ms *MButton:: { static toggle := 1 if toggle := !toggle Click else Click(,, 3) }
Code: Select all
#Requires AutoHotkey 2.0 #SingleInstance *MButton:: { static toggle := 1 , Delay := 100 if toggle := !toggle { Send("{LButton down}"), Sleep(Delay), Send("{LButton up}") } else { Loop 3 Send("{LButton down}"), Sleep(Delay), Send("{LButton up}") } }
this is the code im currently using
Code: Select all
#SingleInstance Force
#Requires AutoHotkey v2
SendMode "Event"
SetMouseDelay(100)
*MButton:: {
static toggle := 1
if toggle := !toggle
send "{Click m }"
else send "{Click 3 m }"
}
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
Re: how to make middle mouse button alternate between inputing three times and once per click
@Theleifblower, please use code tags when posting code! Thank you.
- Theleifblower
- Posts: 12
- Joined: 16 May 2024, 16:12
Re: how to make middle mouse button alternate between inputing three times and once per click
i managed to figure it out myself
Code: Select all
#SingleInstance Force
#Requires AutoHotkey v2
SendMode "event"
blockinput "mouse"
*MButton:: {
static toggle := 1
if toggle := !toggle
Click "Middle"
else Click "3 Middle"
}
- Theleifblower
- Posts: 12
- Joined: 16 May 2024, 16:12
Re: how to make middle mouse button alternate between inputing three times and once per click
but then of course its not fully working, i no longer get the issue with keys being registered while the script is running, but if i release a key im holding while the scrip is running it gets stuck down until i press it again, this is not really very ideal at all either, any thoughts on how this can be fixed?
current script:
current script:
Code: Select all
#SingleInstance Force
#Requires AutoHotkey v2
SendMode "event"
blockinput "mouse"
*MButton:: {
static toggle := 1
if toggle := !toggle
Click "Middle"
else Click "3 Middle"
}
- Theleifblower
- Posts: 12
- Joined: 16 May 2024, 16:12
Re: how to make middle mouse button alternate between inputing three times and once per click
is there any way i can isolate the middle mouse button to be the only key that has its input blocked while the script runs
- Noitalommi_2
- Posts: 321
- Joined: 16 Aug 2023, 10:58
Re: how to make middle mouse button alternate between inputing three times and once per click
Try the second script I posted.Theleifblower wrote: ↑19 May 2024, 23:41is there any way i can isolate the middle mouse button to be the only key that has its input blocked while the script runs