Thank you for replying so quickly with a solution . Sorry, it has taken me this long to test and thank you.
It works but I made modification below so as to work with less than 1 sec (doubles like 0.5, 0.3, as in other wait statements).
Also, I wanted to make it return the value of whether mousewheel forward or backward. I do not understand the CreateEvent, SetWindowsHookEx, MSLLHOOKSTRUCT type functions/arguments very well. I know I should since hooking and subclassing, etc, is the basis of so much of the magic of QM! Perhaps at one point you could comment such a function with explanations or perhaps there is already a good explanation that may be available online or in forum or in QM Help.
In any case, I could only figure out how to do it with a thread integer variable as ret in main waitfunction, set in subfunction and used in calling function to direct subsequent actions. I know it is better practice to try and avoid globals/thread functions when possible and return explicit function variables or pointers. But as above, I couldn't quite figure it out. Here is my best attempt (does work though!):
Thanks again!,
S
Function
WaitForMouseWheel
;/
function# ^waitMaxS direction [flags] ;;direction: 1 forward, -1 backward, 0 any; flags: 1 block event
;Waits for mouse wheel forward or backward.
;waitMaxS - 0 or timeout. Error on timeout. accepts less than 1 sec as decimal e.g. 0.5
;returns -1 for mousewheel backward, 1 for mousewheel forward e.g.
int- mwDirection
opt noerrorshere 1
__Handle ev=CreateEvent(0 0 0 0)
__WindowsHook hook=SetWindowsHookEx(WH_MOUSE_LL &sub.Hook_WH_MOUSE_LL _hinst 0)
opt waitmsg 1
wait waitMaxS H ev
if mwDirection > 0; ret 1
if mwDirection < 0; ret -1
ret mwDirection
#sub Hook_WH_MOUSE_LL v
function# nCode message MSLLHOOKSTRUCT&m
if(nCode<0) goto gNext
if message=WM_MOUSEWHEEL
,int v=m.mouseData
,mwDirection = v
,if direction=0 or (direction>0 and v>0) or (direction<0 and v<0)
,,SetEvent ev
,,if(flags&1) ret 1
;gNext
ret CallNextHookEx(0 nCode message &m)