WM_MOUSEWHEEL wParam hi-word Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ntepa
Posts: 406
Joined: 19 Oct 2022, 20:52

WM_MOUSEWHEEL wParam hi-word

Post by ntepa » 28 Nov 2022, 00:17

https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel wrote:The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
The Microsoft docs say it's a negative value if I rotate backward. When I rotate back, the value is 65416. How do I get a negative value?

Code: Select all

Gui, +AlwaysOnTop
Gui, Show, w200 h100
OnMessage(0x020A, "WM_MOUSEWHEEL")

WM_MOUSEWHEEL(wParam, lParam, msg, hwnd) {
	ToolTip % wParam >> 16
}

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: WM_MOUSEWHEEL wParam hi-word

Post by jNizM » 28 Nov 2022, 02:57

This is really a bit strange

AHK returns 1 and 545.133333

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Edit, vED
Gui, Show, w200 h100
OnMessage(0x020A, "WM_MOUSEWHEEL")
return

WM_MOUSEWHEEL(wParam, lParam, msg, hwnd)
{
	GuiControl,, ED, % (wParam >> 16) / 120
}
while au3 returns 1 and -1

Code: Select all

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>


Global $iCount = 0
Global $hGui = GUICreate('MouseWheel', 320, 240)
Global $idCounter = GUICtrlCreateLabel($iCount, 80, 20, 160, 40, $SS_RIGHT, $WS_EX_STATICEDGE)
GUICtrlSetFont(-1, 28, 800, 0, 'Courier New')
GUICtrlSetBkColor(-1, 0xDDDDDD)
GUISetState(@SW_SHOW, $hGui)
GUIRegisterMsg($WM_MOUSEWHEEL, '_WM_MOUSEWHEEL')
Do
Until GUIGetMsg() = -3
Exit


Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
	Local $iWheel = _WinAPI_HiWord($wParam) / 120 ; down = -1, up = 1
	;$iCount += $iWheel
	GUICtrlSetData($idCounter, $iWheel) ;$iCount
	Return $GUI_RUNDEFMSG
EndFunc
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: WM_MOUSEWHEEL wParam hi-word

Post by jNizM » 28 Nov 2022, 03:02

this works

Code: Select all

Gui, +AlwaysOnTop
Gui, Add, Edit, vED
Gui, Show, w200 h100
OnMessage(0x020A, "WM_MOUSEWHEEL")
return

WM_MOUSEWHEEL(wParam, lParam, msg, hwnd)
{
	if (wParam > 0x7FFFFFFF)
		wParam := -(~wParam) - 1
	GuiControl,, ED, % (wParam >> 16) / 120
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

teadrinker
Posts: 4309
Joined: 29 Mar 2015, 09:41
Contact:

Re: WM_MOUSEWHEEL wParam hi-word  Topic is solved

Post by teadrinker » 28 Nov 2022, 03:38

Code: Select all

Gui, +AlwaysOnTop
Gui, Show, w200 h100
OnMessage(0x020A, "WM_MOUSEWHEEL")

WM_MOUSEWHEEL(wParam, lParam, msg, hwnd) {
   ToolTip % wParam >> 16 << 48 >> 48
}

ntepa
Posts: 406
Joined: 19 Oct 2022, 20:52

Re: WM_MOUSEWHEEL wParam hi-word

Post by ntepa » 28 Nov 2022, 04:12

thank you @jNizM and @teadrinker

just me
Posts: 9424
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: WM_MOUSEWHEEL wParam hi-word

Post by just me » 29 Nov 2022, 06:43

A little less back and forth ;)

Code: Select all

ToolTip % wParam << 32 >> 48


Post Reply

Return to “Ask for Help (v1)”