Is there any way you can use the scroll wheel, scroll through menu?
I found the Firefox Bookmarks menu can use the wheel to scroll.

Code: Select all
loop 200
Menu, MyMenu, Add, Item%A_Index%, M
Menu, MyMenu, Show
return
M:
return
Code: Select all
loop 200
Menu, MyMenu, Add, Item%A_Index%, M
Menu, MyMenu, Show
return
M:
return
not the standard menu, firefox has all the control over the menu, the system doesn't interfere with its messagesI found the Firefox Bookmarks menu can use the wheel to scroll
Code: Select all
GUI +HWNDwindowname ;Put this before your GUI
#If WinActive("ahk_id " windowname) ;Put all of this at the end of your script
WheelDown::
Send, {Down}
Return
WheelUp::
Send, {Up}
Return
can you explain a little bit what you meanWIN menu is not a roll of API.
there are some work around, but not straight forward ones.MSDN wrote: during a modal loop, the system retrieves and dispatches messages without allowing an application the chance to filter the messages in its main message loop
I haven't tested it, but it might work.MSDN wrote:MNS_MODELESS: Menu is modeless; that is, there is no menu modal message loop while the menu is active.
Code: Select all
WheelDown::
WheelUp::
hWnd := WinExist("ahk_class #32768") ; menu class
WinGetPos, x, y, w, h
(A_ThisHotkey="WheelDown") ? Wheel2Click(x+20, y+h-20, hWnd) : Wheel2Click(x+20, y+5, hWnd) ; the 20s and 5 are from testing only no calculations
return
Wheel2Click(x, y, hWnd) { ; posting clicks without moving the mouse
; WM_LBUTTONDOWN: https://msdn.microsoft.com/en-us/library/windows/desktop/ms645607(v=vs.85).aspx
lParam := x + (y << 16)
PostMessage, 0x0201, 0x0001, lParam, , ahk_id %hWnd% ; WM_LBUTTONDOWN:=0x0201, MK_LBUTTON:=0x0001
PostMessage, 0x0202 , 0, lParam, , ahk_id %hWnd% ; WM_LBUTTONUP:=0x0202
}
Code: Select all
Space::
Loop, 26
menu, Long_Long_Menu, add, % chr(64+A_Index) "_First", MenuHandler
Loop, 26
menu, Long_Long_Menu, add, % chr(64+A_Index) "_Next", MenuHandler
menu, Long_Long_Menu, show
return
MenuHandler:
MsgBox, % A_ThisMenuItem
return
esc::
ExitApp
Code: Select all
Space::
Loop, 2
menu, Long_Long_Menu, add, % chr(64+A_Index) "_First", MenuHandler
Loop, 2
menu, Long_Long_Menu, add, % chr(64+A_Index) "_Next", MenuHandler
menu, Long_Long_Menu, show
return
MenuHandler:
MsgBox, % A_ThisMenuItem
return
esc::
ExitApp
MJs wrote: CAREFUL: THIS WOULD PRESS THE LAST OR FIRST ITEM IN THE CONTEXT MENU IF THERE WERE NO UP/DOWN ARROW
I'll leave knowing if the menu has an up/down arrow to scroll in the first place, and no DPI awareness!
ok, then:arcticir wrote:Sorry, my English is very bad, I did not immediately understand what you said.
So, how to know if the menu has an up/down arrow?
Code: Select all
#if INFO:=IsLongLongMenu()
WheelDown::
WheelUp::
(A_ThisHotkey="WheelDown") ? Wheel2Click(INFO.x+20, INFO.y+INFO.h-20, INFO.hWnd) : Wheel2Click(INFO.x+20, INFO.y+5, INFO.hWnd)
return
#if
Wheel2Click(x, y, hWnd) { ; Left or right buttons
lParam := x + (y << 16)
PostMessage, 0x0201, 0x0001, lParam, , ahk_id %hWnd% ; WM_LBUTTONDOWN:=0x0201, MK_LBUTTON:=0x0001
PostMessage, 0x0202 , 0, lParam, , ahk_id %hWnd% ; WM_LBUTTONUP:=0x0202
}
IsLongLongMenu(){ ; this is testing and calculating based on basic understading
hWnd := WinExist("ahk_class #32768")
SendMessage, 0x01E1 ; MN_GETHMENU:=0x01E1 : Retrieves the menu handle for the current window
hMenu := errorlevel
VarSetCapacity(rect, 16, 0)
DllCall("GetMenuItemRect", uInt, 0, uInt, hMenu, uInt, 0, uInt, &rect) ; get the rect of the top menu item
WinGetPos, x, y, w, h ; get the popup menu rect
return, ((NumGet(rect, 4)-y)>10) ? {hWnd:hWnd, x:x, y:y,h:h} : 0 ; the up/down arrow on a 96 DPI setting is 20, so that would be the minumum I'd think
}
MJs wrote: ↑31 Jul 2015, 22:14ok, then:arcticir wrote:Sorry, my English is very bad, I did not immediately understand what you said.
So, how to know if the menu has an up/down arrow?CAREFUL: TEST AND SEARCHCode: Select all
#if INFO:=IsLongLongMenu() WheelDown:: WheelUp:: (A_ThisHotkey="WheelDown") ? Wheel2Click(INFO.x+20, INFO.y+INFO.h-20, INFO.hWnd) : Wheel2Click(INFO.x+20, INFO.y+5, INFO.hWnd) return #if Wheel2Click(x, y, hWnd) { ; Left or right buttons lParam := x + (y << 16) PostMessage, 0x0201, 0x0001, lParam, , ahk_id %hWnd% ; WM_LBUTTONDOWN:=0x0201, MK_LBUTTON:=0x0001 PostMessage, 0x0202 , 0, lParam, , ahk_id %hWnd% ; WM_LBUTTONUP:=0x0202 } IsLongLongMenu(){ ; this is testing and calculating based on basic understading hWnd := WinExist("ahk_class #32768") SendMessage, 0x01E1 ; MN_GETHMENU:=0x01E1 : Retrieves the menu handle for the current window hMenu := errorlevel VarSetCapacity(rect, 16, 0) DllCall("GetMenuItemRect", uInt, 0, uInt, hMenu, uInt, 0, uInt, &rect) ; get the rect of the top menu item WinGetPos, x, y, w, h ; get the popup menu rect return, ((NumGet(rect, 4)-y)>10) ? {hWnd:hWnd, x:x, y:y,h:h} : 0 ; the up/down arrow on a 96 DPI setting is 20, so that would be the minumum I'd think }