It will be very helpful feature!
Thanks!
I agree with space on this one. There would be no purpose since one could very easily make a function to use with the #if in an expression.
I found no way to remap mouse wheel only when cursor hovers control with ClassNN in some app window. Can you explain me, please, how can i make this ?
I tried this:
#IfWinActive ahk_class dopus.lister ; if Directory Opus Lister window is active SetTimer, CtrlChk, 50 ; runs the 'CtrlChk' subroutine once a second return CtrlChk: MouseGetPos, , , WhichWindow, WhichControl ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow% if (WhichControl = "some_name") { ToolTip, %WhichControl%`nX%X%`tY%Y%`nW%W%`t%H% WheelDown::Send, {Control Down}{Left}{Control Up} WheelUp::Send, {Control Down}{Right}{Control Up} }
But to no avail (
The #IfWinActive and other #if commends can not be used like that.
They affect hotkeys and hotstrings nothing else, so your timer will always run and normal if statements have no effect on hotkey or hotstring label definitions.
the help file shows this example
; Example 1: Adjust volume by scrolling the mouse wheel over the taskbar. #If MouseIsOver("ahk_class dopus.lister") WheelUp::Send {Volume_Up} WheelDown::Send {Volume_Down} MouseIsOver(WinTitle) { MouseGetPos,,, Win return WinExist(WinTitle . " ahk_id " . Win) }
you can then modify that to try and check for a control
The #IfWinActive and other #if commends can not be used like that.
They affect hotkeys and hotstrings nothing else, so your time will always run and normal if statements have no effect on hotkey or hotstring label definitions.
the help file shows this example
; Example 1: Adjust volume by scrolling the mouse wheel over the taskbar. #If MouseIsOver("ahk_class dopus.lister") WheelUp::Send {Volume_Up} WheelDown::Send {Volume_Down} MouseIsOver(WinTitle) { MouseGetPos,,, Win return WinExist(WinTitle . " ahk_id " . Win) }you can then modify that to try and check for a control
I have no idea how i should modify this ? This just doesn't work, i tried all options, even downloaded, installed and ran all code snippets under debugger. There is totally no way to remap when detected mouse over ClassNN in AutoHotKey framework! Everybody just saying that this is possible, but it's not (
So i think my suggestion will be very helpful.
How about you try asking other users by making a topic in the "ask for help" sub forum about your issue? That's a great place to get support when you're unsure of how to modify scripts...
At last, i just made it, and it even works somehow:
#If MouseIsOver("some_name") ~WheelUp::Send, {Control Down}{Left}{Control Up} ~WheelDown::Send, {Control Down}{Right}{Control Up} MouseIsOver(WinTitle) { MouseGetPos, , , WhichWindow, WhichControl ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow% if (WhichControl = WinTitle) { return 1 ;WinExist(WinTitle . " ahk_id " . Win) } else { return 0 } }
Anyway, all this code would end up with just these lines, if my suggestion will be implemented ):
#IfMouseOverControl "some_name" ~WheelUp::Send, {Control}{Up} ~WheelDown::Send, {Control}{Down}
And by the way, this will not work if window is not active.
So it's a lot to do.
Thank you to all!
ps: sorry for my english
That is not a lot of code. Also, some of it is unnecessary. You get the position of the control, but never do anything with it. The IF, braces and separate return statements can be reduced to a single statement:Anyway, all this code would end up with just these lines, if my suggestion will be implemented
#If MouseIsOverControl("some_name") ~WheelUp::Send, ^{Left} ~WheelDown::Send, ^{Right} MouseIsOverControl(QueryControl) { MouseGetPos, , , , MouseControl return (MouseControl = QueryControl) }You only need to write the function once, then you can use it with as many hotkeys as you want.
I'm not sure what you're trying to say, but I did observe that the keystrokes are sent to the focused control in the active window, not the control the mouse is pointing to, so it's not very sensible to have the hotkey work this way. This might fix it:And by the way, this will not work if window is not active.
So it's a lot to do.
~WheelUp:: WinActivate ControlFocus some_name Send, ^{Left} return... or you could check the keyboard focus (WinActive/ControlGetFocus) instead of the mouse position. It seems unlikely that the user will want to move the caret (keyboard insertion point) by pointing the mouse at a control when the caret isn't even in that control.
I'm not sure what you're trying to say, but I did observe that the keystrokes are sent to the focused control in the active window, not the control the mouse is pointing to, so it's not very sensible to have the hotkey work this way.
I'm trying to say, that this will not work if the visible window have no focus, i.e. not active. So, i'm getting ControlGetPos to compare with MouseGetPos and trying to remap in case when mouse hovers over control.
Thank you for comment!