Intercepting mousewheel Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Intercepting mousewheel

Post by Ryder » 12 Aug 2022, 16:03

Hi all,

I need to intercept mousewheel movement and direct it to another (titled) window... but no clue how...

I suppose it's ok to not *intercept* it (ie, prevent it acting on current window), and duplicating it on another window, but it's best to intercept it.

Ideas?

Thank you!!!

wetware05
Posts: 750
Joined: 04 Dec 2020, 16:09

Re: Intercepting mousewheel

Post by wetware05 » 12 Aug 2022, 17:15

Hi :wave:

I can only think of using a settimer where the mouse position is recorded in a file (FileAppend or in an array) through the MouseGetPos command. The MouseMove command would then be used to replicate it, modifying each value to make it work on the second monitor.

On this page they do something similar, but of the times the left mouse button is clicked: viewtopic.php?t=73287

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

Re: Intercepting mousewheel

Post by mikeyww » 12 Aug 2022, 20:31

Code: Select all

; Disable "Scroll inactive windows when I hover over them" in Windows Mouse settings
WheelDown::
hWnd := WinActive("A")
WinActivate, ahk_exe notepad.exe
SoundBeep, 1500
#If hWnd
WheelDown::
Send {WheelDown}
SetTimer, Back, -400
Return
#If
Back:
WinActivate, ahk_id %hWnd%
SoundBeep, 1000
hWnd := False
Return

Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Re: Intercepting mousewheel

Post by Ryder » 15 Aug 2022, 11:32

This solution works very well... THANK YOU!

Ryder

Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Re: Intercepting mousewheel

Post by Ryder » 15 Aug 2022, 11:42

mikeyww wrote:
12 Aug 2022, 20:31

Code: Select all

; Disable "Scroll inactive windows when I hover over them" in Windows Mouse settings
WheelDown::
hWnd := WinActive("A")
WinActivate, ahk_exe notepad.exe
SoundBeep, 1500
#If hWnd
WheelDown::
Send {WheelDown}
SetTimer, Back, -400
Return
#If
Back:
WinActivate, ahk_id %hWnd%
SoundBeep, 1000
hWnd := False
Return

Now if I could ask another question to properly implement this... how would one change it so that it worked ONLY when the mouse was over a certain GUI button?

In other words... imagine this firing ONLY when I put the mouse over the "Scroll Here" GUI button...

Thank you again for your kind help,

R

Ryder
Posts: 61
Joined: 28 Apr 2022, 18:49

Re: Intercepting mousewheel  Topic is solved

Post by Ryder » 15 Aug 2022, 19:02

Ryder wrote:
15 Aug 2022, 11:42
Now if I could ask another question to properly implement this... how would one change it so that it worked ONLY when the mouse was over a certain GUI button?

In other words... imagine this firing ONLY when I put the mouse over the "Scroll Here" GUI button...

Thank you again for your kind help,

R
I was able to use this approach instead... seems to work properly! Much simpler than I thought it would be. Yay!

Code: Select all

#SingleInstance, Force

Gui, Margin, 10, 10
Gui, Add, Button, w80 h24 HWNDhButton1, Button 1
Gui, Show, w400 h200, Example
WinSet, AlwaysOnTop, On, Example
return

WheelDown::
	MouseGetPos, MouseX, MouseY, MouseWin, MouseCtl, 2
	
	If (MouseCtl = hButton1) {
		ControlClick, ,MyText.txt - Notepad, , WheelDown 
	}
return

WheelUp::
	MouseGetPos, MouseX, MouseY, MouseWin, MouseCtl, 2
	
	If (MouseCtl = hButton1) {
		ControlClick, ,MyText.txt - Notepad, , WheelUP
	} 
return

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

Re: Intercepting mousewheel

Post by mikeyww » 15 Aug 2022, 19:38

Nice. I actually had some problems with my earlier script, so your update looks like an improvement.

Post Reply

Return to “Ask for Help (v1)”