Help with Right click hold + Wheel up/down

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
iorgu
Posts: 32
Joined: 03 May 2023, 17:56

Re: Help with Right click hold + Wheel up/down

Post by iorgu » 04 May 2023, 17:34

Yes, thanks so much for helping. It seemed like an easy thing to achieve, or so i thought, but i'm not so sure at the moment. I want to keep the button's main function, just ignore the release action after a few conditions are met, like the wheel was used with the button held down for example.

As i went through the thread again, this cleared it for me.
I am not aware of a way to send a button up without having Windows do whatever it usually does when the button is sent up.
I must start reading, learning, trying things out and see what options i have, if any.

User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Help with Right click hold + Wheel up/down

Post by Tigerlily » 04 May 2023, 18:55

@iorgu

Hello kind ser. I tried this script out that I made and it worked the way you describe you want.

If you just press RButton then you get the context menu, however if you scroll with the wheels to zoom in and out, then context menu still opens BUT you never see it because the script listens for the Key Release using KeyWait and as soon as the menu is fired, the ESC key cancels it out. Give it a whirl and LMK if this works.

Code: Select all

~RButton & WheelUp::{

    Send '^{WheelUp}'
    KeyWait("RButton")
    Send '{Esc}'
}

~RButton & WheelDown::{

    Send '^{WheelDown}'
    KeyWait("RButton")
    Send '{Esc}'
}

Cheers.
-TL

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

Re: Help with Right click hold + Wheel up/down

Post by mikeyww » 04 May 2023, 19:21

A good idea, but no luck here with that.

My suggestion is still to use the brief delay (hold) option.

User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: Help with Right click hold + Wheel up/down

Post by Tigerlily » 04 May 2023, 19:27

@mikeyww

ya oddly this was working on my system right before i posted, but now it is no longer allowing me to continuously zoom in/out and only allows 1 zoom click before waiting for the RButton. But the fact that my system was doing it breifly (I think two scripts were running simultaneously and creating the intended effect cuz some weird temporary ahk script was running (never seen this before) once I closed it I couldn't reproduce the intended effect. merp XD ill try somethin else and post back in a bit.
-TL

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

Re: Help with Right click hold + Wheel up/down

Post by mikeyww » 04 May 2023, 20:03

My update is below.

Code: Select all

#Requires AutoHotkey v2.0
XButton1 Up::Send A_PriorKey = 'XButton1' ? '{XButton1}' : '{Ctrl up}'
#HotIf GetKeyState('XButton1', 'P')
WheelUp::
WheelDown::
^WheelUp::
^WheelDown:: {
 Send GetKeyState('Ctrl') ? '' : '{Ctrl down}'
 Send '{Blind}{' StrReplace(ThisHotkey, '^') '}'
}
#HotIf

iorgu
Posts: 32
Joined: 03 May 2023, 17:56

Re: Help with Right click hold + Wheel up/down

Post by iorgu » 05 May 2023, 05:53

Damn! This code works perfectly!
There is no scroll leak, native function is not affected when you intend to use XButton1 as back key. Just beautiful!

I was about to give up yesterday... While looking up info to try my hand at the issue, i found this thread that i thought was relevant: viewtopic.php?t=70803

Then i stumbled upon an extension for chrome, "Scroll Zoom". It does exactly what i needed, but only in chrome. Hold RB and use the wheel to zoom in and out. When you release RB, context menu isn't triggered.

Now i can zoom in and out in chrome with RB + wheel and anywhere else with the back button + wheel.

Thanks again, mikeyww!

Post Reply

Return to “Ask for Help (v2)”