Scroll Wheel Remap - Intermittent Functionality Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
luchvk
Posts: 3
Joined: 13 Sep 2019, 19:49

Scroll Wheel Remap - Intermittent Functionality

13 Sep 2019, 21:56

Hello, this is my first forum post.

I'm hoping that someone could help me with an issue that I'm facing. I'm currently working on a script that remaps the scroll wheel when an executable is active. The script functions. However, the issue is that if I scroll the wheel fast enough normal wheel movements can get through. This is reliable and easily repeatable.

I've been searching for something that can fix this but I haven't found anything that works yet. I've used "A_EventInfo", as included in AHK's documentation, to check my mouse and the tooltip always shows a "1" regardless of how fast I scroll the wheel. I've done a host of other tests with other functions too. I'm thinking that is has something to do with the speed of the script but I'm not sure.

It's a very simple script so I don't know how I can speed it up; if that's what I need to do. Does anyone have any suggestions? Thanks in advance.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#InstallKeybdHook
#UseHook On
sendmode, Input

#InstallMouseHook
#UseHook On
sendmode, Input

;; comment
;; comment
;; comment

	
SetTitleMatchMode, 2

Hotkey, IfWinActive, ahk_exe applicationframehost.exe
Hotkey, ^WheelDown, RightPhoto  

Hotkey, IfWinActive, ahk_exe applicationframehost.exe
Hotkey, ^WheelUp, LeftPhoto  

return

RightPhoto:
ControlGetFocus, fcontrol, A
SendInput, {Right down}{Right up}
return

LeftPhoto:
ControlGetFocus, fcontrol, A
SendInput, {Left down}{Left up}
return

<^<#MButton::
	Hotkey, ^WheelDown, toggle
	Hotkey, ^WheelUp, toggle
	;Suspend
	;Pause
	return
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Scroll Wheel Remap - Intermittent Functionality

14 Sep 2019, 01:53

Hallo,
only a try:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#InstallKeybdHook
#UseHook On
sendmode, Input

;; comment
;; comment
;; comment

SetTitleMatchMode, 2
<^<#MButton::Toggle := !Toggle

#If !Toggle And WinActive("ahk_exe applicationframehost.exe")
^WheelDown:: ;RightPhoto
ControlGetFocus, fcontrol, A
SendInput, {Right down}{Right up}
return
^WheelUp:: ;LeftPhoto
ControlGetFocus, fcontrol, A
SendInput, {Left down}{Left up}
return
#If
User avatar
luchvk
Posts: 3
Joined: 13 Sep 2019, 19:49

Re: Scroll Wheel Remap - Intermittent Functionality

16 Sep 2019, 13:21

Rohwedder wrote:
14 Sep 2019, 01:53
Hallo,
only a try:

Code: Select all

"Code"
I didn't get notified of your reply. So it took me somewhat longer to reply.

Your script changes the buttons over properly but I'm still getting the same issue. Thanks for the attempt though.
User avatar
luchvk
Posts: 3
Joined: 13 Sep 2019, 19:49

Re: Scroll Wheel Remap - Intermittent Functionality  Topic is solved

18 Sep 2019, 17:50

Ok, so I've found a fix for this issue. I still don't fully understand why it works but I'll look into it some more. Basically, I just needed to change how to the hotkey was formatted. Instead of "^WheelUp" as the hotkey, for example, I needed to enter "~Control & WheelUp" ("Control & WheelUp" works as well). Also, I'm not sure if it's better for the tilde prefix to be present with this hotkey but I'll just leave it for now as I haven't noticed any issues with it yet. I've adjusted the "MaxHotkeysPerInterval" value too because I was getting a pop-up message if I scrolled the wheel fast enough.

Here's the new code:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#InstallKeybdHook
#InstallMouseHook
#UseHook On

;; comment
;; comment
;; comment


#MaxHotkeysPerInterval 150

SetTitleMatchMode, 2

Hotkey, IfWinActive, ahk_exe applicationframehost.exe
;Hotkey, ^WheelDown, RightPhoto  ; causes scrolling issue
Hotkey, ~Control & WheelDown, RightPhoto

Hotkey, IfWinActive, ahk_exe applicationframehost.exe
;Hotkey, ^WheelUp, LeftPhoto  ; causes scrolling issue
Hotkey, ~Control & WheelUp, LeftPhoto

return

RightPhoto:
;ControlGetFocus, fcontrol, A ; not essential for this case
SendInput, {Right down}{Right up}
return

LeftPhoto:
;ControlGetFocus, fcontrol, A ; not essential for this case
SendInput, {Left down}{Left up}
return

<^<#MButton::
	Hotkey, ~Control & WheelDown, toggle
	Hotkey, ~Control & WheelUp, toggle
	;Suspend
	;Pause
	return

- - UPDATE - -


I'm updating my post to include another method that seems to work well. I haven't encountered any scrolling issues with this other method either; after everything is set up properly.

The aforementioned method is to use BlockInput. What I'm using, specifically, for another similar script is "BlockInput Send". The script needs to run with UI Access but using BlockInput in conjunction with GetKeyState allows me to use multiple modifiers with the scroll wheel.

Here are snippets of the code:

Code: Select all

SendMode Event

#InstallKeybdHook
#InstallMouseHook
#UseHook On

(code)

Hotkey, IfWinActive ; here to cancel a previous "Hotkey, If" sub-command and also for potential use in the future
Hotkey, IfWinNotActive ; here to cancel a previous "Hotkey, If" sub-command and also for potential use in the future
Hotkey, ~LShift & WheelUp, WU_Mode2/3

(code)

WU_Mode2/3:
; Mode3
If GetKeyState("LControl")
	{
	BlockInput Send
	Send, ^{NumpadAdd}
	return
	}
Else
; Mode2
	SendInput, {WheelLeft}
return

(code)
Last edited by luchvk on 13 Oct 2019, 13:04, edited 3 times in total.
User avatar
gwarble
Posts: 524
Joined: 30 Sep 2013, 15:01

Re: Scroll Wheel Remap - Intermittent Functionality

18 Sep 2019, 19:26

interesting, thanks for posting your own solution
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Nerafius and 89 guests