AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Send mouse scrolls to window under mouse
Goto page Previous  1, 2, 3, 4
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
RobOtter



Joined: 30 Jan 2005
Posts: 130
Location: Darmstadt, Germany

PostPosted: Thu Feb 21, 2008 9:33 am    Post subject: Reply with quote

automaticman wrote:
What is the most flexible use for the middle mouse button (as we have found a very good one for the wheel now). I would like to make it dependent on the used application. KatMouse seems to have an option for "pushing windows into the background" if I understood it correctly from the description on its website.

I do not use the "push down" functionality since I don´t need it. But you can configure another button than wheel button (if your mouse has additional ones) to push down windows. KatMouse has only limited per-application settings: you can deactive support for single applications but can not define different actions of mouse buttons for different apps. I use my mouse driver for these purposes (MS IntelliPoint driver).

But it gets off-topic now... If you have further questions, please email me directly.

regards,
Rob
Back to top
View user's profile Send private message
automaticman



Joined: 27 Oct 2006
Posts: 519

PostPosted: Thu Feb 21, 2008 5:04 pm    Post subject: Reply with quote

shimanov wrote:
Code:
CoordMode, Mouse, Screen
return

WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return

WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return
To make use of my so beloved markup:
~ I compare this solution to digging for oil very deeply to get the powerful oil. (Powerful in terms of "oil can be converted into power" meaning it's just one form of power among many other forms like e.g. money, beautiness, intelligence, physical power, military power, mass, accelerated objects, changing anything changeable in any space...)

Where does it's power come from:
+ DllCall
+ SendMessage
+ << operations (one needs some amount of understanding of Knuth's books here)

The used principle might be formulated like: "Connect simple events like here mouse over with low-level events using e.g. DllCall, SendMessage and bitshift operations."

If anyone wants to find a topic to write a nice tutorial about, the three big plus signs above might be some hints.
Back to top
View user's profile Send private message
Hammillian7



Joined: 08 Jun 2008
Posts: 9
Location: Spain - Madrid

PostPosted: Wed Jun 11, 2008 2:19 am    Post subject: And a Horizontal Scroll version? Reply with quote

I love mouse scrolling and use it a lot (now with Dexxa Mouse driver, which works for me with a Logitech wireless Mouse).

What I want is scrolling the control under the mouse, even if not active.

I tried this sample, derived from the documentation:

Code:

~RAlt & WheelDown::  ; Scroll right.
ControlGetFocus, fcontrol, A
MouseGetPos, , , id, control

Loop 1  ; <-- Increase this value to scroll faster.
{
    SendMessage, 0x114, 1, 0, %fcontrol%, A  ; 0x114 is WM_HSCROLL and the 1 after it is SB_LINELEFT.
    SendMessage, 0x114, 1, 0, %control%, A  ; 0x114 is WM_HSCROLL and the 1 after it is SB_LINELEFT.
}
return


It has 2 parts merged, because some applications are responsive to one kind and others to the other.

But it doesn't work in Excel, Access, etc.

Would it be easy to adapt your vertical examples (which I hadn't had time to try yet) to horizontal scrolling?

Thanks.
_________________
Regards.
Back to top
View user's profile Send private message
sashabe



Joined: 09 Oct 2006
Posts: 19

PostPosted: Thu Jul 09, 2009 12:35 pm    Post subject: Reply with quote

shimanov wrote:
Here is a simple alternative. It actually works quite well. Well enough that I have finally removed KatMouse from my system.

note: should work with Windows 98+

Code:
CoordMode, Mouse, Screen
return

WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return

WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return


For me only this version work (scrolling breaks with others at all), but it scrolls only background window, no working scrolling with the foremost one. So I changed the shortcut to !Wheel, now i scroll foremost windows without Alt and background windows with it.
Back to top
View user's profile Send private message
Smurth



Joined: 13 Dec 2006
Posts: 106

PostPosted: Fri Jul 10, 2009 11:10 am    Post subject: Reply with quote

Another varaint; mostly cosmetic changes:
Code:
CoordMode, Mouse, Screen
SetWinDelay, -1
SetBatchLines,-1
SetKeyDelay, -1

; acceleration
_WHEELACC=0x280000
; max speed
_WHEELMAXN=0x1800000
; automatically activate window
_WHEELAUTOFOCUS=1

return


EasyWheel(d)
; if _WHEELAUTOFOCUS if set, check which window is under the mouse and gives it focus if it hasn't already
; then send scroll event to the control under the mouse
; original code from Shimanov: http://www.autohotkey.com/forum/viewtopic.php?t=6772#54821
{
Global _WHEELACC
   , _WHEELMAXN
   , _WHEELAUTOFOCUS
Static t, s


   if ( A_TickCount > 500+t) {
      t := A_TickCount
      s :=0x780000
   }
   else if (s < _WHEELMAXN)
      s += _WHEELACC

   MouseGetPos x, y, hwnd
   h := DllCall("WindowFromPoint", "int", x, "int", y)
   if _WHEELAUTOFOCUS && (hwnd<>WinExist("A"))
      WinActivate, ahk_id %hwnd%
   SendMessage, 0x20A, d*s,(y<<16)|x,, ahk_id %h%
}


WheelUp:: EasyWheel(1)
WheelDown:: EasyWheel(-1)
Back to top
View user's profile Send private message
soggos



Joined: 27 Mar 2008
Posts: 105
Location: France

PostPosted: Sat Jul 25, 2009 10:40 am    Post subject: Reply with quote

sashabe wrote:
shimanov wrote:
Here is a simple alternative. It actually works quite well. Well enough that I have finally removed KatMouse from my system.

note: should work with Windows 98+

Code:
CoordMode, Mouse, Screen
return

WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return

WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return


For me only this version work (scrolling breaks with others at all), but it scrolls only background window, no working scrolling with the foremost one. So I changed the shortcut to !Wheel, now i scroll foremost windows without Alt and background windows with it.


Good and Great for me to, i like the scrolling without windows focused,
Simple and Effective, big thank's AHK-Forum
_________________
since ahk, all is different!
Back to top
View user's profile Send private message Visit poster's website
thx1200



Joined: 19 Aug 2009
Posts: 1

PostPosted: Wed Aug 19, 2009 6:06 pm    Post subject: Workaround for Trillian Astra Reply with quote

I found a program that doesn't like the very elegant solution by shimanov: Trillian Astra. Wheel scrolling doesn't work at all in Trillian's message windows while this script is active.

As a workaround, I look to see what the active app and hovered app are and send the default wheel messages if they are both trillian.exe. Unfortunately, that means no "hover scroll" for Trillian, but that's better than no wheel scrolling at all!

Code:

$WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )
   WinGet,hoverproc,ProcessName,ahk_id %hw_m_target%
   WinGet,activeproc,ProcessName,A
   if (hoverproc = "trillian.exe" and activeproc = "trillian.exe")
   {
     Send,{WheelUp}
   }
   else
   {
     SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
   }
return

$WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )
   WinGet,hoverproc,ProcessName,ahk_id %hw_m_target%
   WinGet,activeproc,ProcessName,A
   if (hoverproc = "trillian.exe" and activeproc = "trillian.exe")
   {
     Send,{WheelDown}
   }
   else
   {
     SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
   }
return
Back to top
View user's profile Send private message
iDrug



Joined: 13 Oct 2009
Posts: 9

PostPosted: Tue Oct 13, 2009 12:20 pm    Post subject: Reply with quote

Hi there!

I need your help. I know nothing about scripting/programming at all, so please, if it's not that hard for you: could you please adopt this script for my needs?

I use Firefox, Total Commander and Miranda (TabSRMM chat container + clist_modern). All these progs use tabs. Miranda and Firefox have it's own abilities to scroll tabs, and Total Commander hasn't.

I want to have a script that will be able to scroll anything under the cursor without activating it (and without scroll acceleration).

I've tried all of the scripts from this topic and each of them does only part of what I need, but this parts are different, so maybe it's possible to mix all the advantages of these scripts, throw away all disadvantages and then combine them into one single script.

Here are the exact details of what I need:
1. No activation of the scrollable objects.
2. Tab scroll for the 3 programs mentioned above.
3. No scroll acceleration.

In order to try to help you helping me:
The only script that partially (it has some bugs) supports scroll for miranda's container tabs is TheLeO's version of the script.

All other scripts brake the built-in ability of (at least) Miranda (or even Firefox's too). But even this script is not bug-free: when scrolling active window of chat log or tabs in the chat container (TabSRMM), it also scrolls contact list (bug works only for my lovely clist_modern, but not for clist_nicer, btw).

EDIT:
Code:
#SingleInstance force
; Run total commander.
Run, TOTALCMD.EXE

; Wait until it opens.
WinWait, ahk_class TTOTAL_CMD

; Setting timer to check if the process still alive.
SetTimer, CheckTC, On

WheelUp::
WheelDown::
  MouseGetPos, MouseX, MouseY, WinID, ControlNN, 1
  WinGetClass, WinClass, % "ahk_id " WinID

  ; Scrolling TotalCommander's tabs
  If (WinClass = "TTOTAL_CMD" && RegExMatch(ControlNN, "TMyTabControl[12]"))
  { PostMessage, 1075, % TC_Cmd := "400" (ControlNN = "TMyTabControl1" ? "1" : "2"), 0,, % "ahk_class " WinClass
    PostMessage, 1075, % TC_Cmd := "300" (A_ThisHotkey = "WheelDown" ? "5" : "6"), 0,, % "ahk_class " WinClass
  }

  ; Scrolling objects under cursor without activation.
  Else, PostMessage 0x20A, ((A_ThisHotKey="WheelUp")-.5)*A_EventInfo*(120<<17),(MouseY<<16)|MouseX, % ControlNN, % "ahk_id " WinID
Return

CheckTC:
  Process, Exist, TOTALCMD.EXE
  If !ErrorLevel
    ExitApp
Return

This script was written by Mad*Forces / ZeLen1y under WTFPL license and it works best for TotalCommander - it can scroll inactive part of window without activating it, can scroll tabs of (in)active part of window, can scroll foreground applications and explorer windows, also without activating them, but it works bad with firefox: if firefox is not active, and I try to scroll tabs or tab's content - nothing happens.
It works good with (in)active TabSRMM chat container, but not with it's tabs.
Please, ignore the timer, as this script was written specially for me and I really requested that thing.
Back to top
View user's profile Send private message
iDrug



Joined: 13 Oct 2009
Posts: 9

PostPosted: Thu Oct 15, 2009 2:37 pm    Post subject: Reply with quote

please, don't ignore my post, I really need help badly! :(
Back to top
View user's profile Send private message
fragman



Joined: 13 Oct 2009
Posts: 246

PostPosted: Thu Feb 18, 2010 4:52 pm    Post subject: Re: Workaround for Trillian Astra Reply with quote

thx1200 wrote:
I found a program that doesn't like the very elegant solution by shimanov: Trillian Astra. Wheel scrolling doesn't work at all in Trillian's message windows while this script is active.

As a workaround, I look to see what the active app and hovered app are and send the default wheel messages if they are both trillian.exe. Unfortunately, that means no "hover scroll" for Trillian, but that's better than no wheel scrolling at all!

Code:

$WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )
   WinGet,hoverproc,ProcessName,ahk_id %hw_m_target%
   WinGet,activeproc,ProcessName,A
   if (hoverproc = "trillian.exe" and activeproc = "trillian.exe")
   {
     Send,{WheelUp}
   }
   else
   {
     SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
   }
return

$WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )
   WinGet,hoverproc,ProcessName,ahk_id %hw_m_target%
   WinGet,activeproc,ProcessName,A
   if (hoverproc = "trillian.exe" and activeproc = "trillian.exe")
   {
     Send,{WheelDown}
   }
   else
   {
     SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
   }
return


I think trillian needs the scroll event to be send to the textbox control in chat window. With a scroll script active, it scrolls only if I have the cursor over the textbox area. Unfortunately the ClassNN is the same for the chat log control above it, and if you use Tabs, the number at the end of classNN appears to be random. Comparing the positions and visibility of the controls might be a way to find the correct one.

I also noticed another program that has issues with it, AdiIRC (probably not so common, but I use it). It zooms the chat window when you scroll too fast...
Back to top
View user's profile Send private message
jeffwalker



Joined: 22 Feb 2010
Posts: 1

PostPosted: Tue Feb 23, 2010 12:03 am    Post subject: Reply with quote

soggos wrote:
sashabe wrote:
shimanov wrote:
Here is a simple alternative. It actually works quite well. Well enough that I have finally removed KatMouse from my system.

note: should work with Windows 98+

Code:
CoordMode, Mouse, Screen
return

WheelUp::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, 120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return

WheelDown::
   MouseGetPos, m_x, m_y
   hw_m_target := DllCall( "WindowFromPoint", "int", m_x, "int", m_y )

   ; WM_MOUSEWHEEL
   ;   WHEEL_DELTA = 120
   SendMessage, 0x20A, -120 << 16, ( m_y << 16 )|m_x,, ahk_id %hw_m_target%
return


For me only this version work (scrolling breaks with others at all), but it scrolls only background window, no working scrolling with the foremost one. So I changed the shortcut to !Wheel, now i scroll foremost windows without Alt and background windows with it.


Good and Great for me to, i like the scrolling without windows focused,
Simple and Effective, big thank's AHK-Forum


Thanks for this. I like it a lot. One thing, I used to have "~LControl & WheelUp" and down mapped to scroll to the left and right. It of course broke when I started using this script.

I tried replacing "0x20A" with "0x114" which is "WM_HSCROLL" which was used in my old hotkey, but that doesn't do anything. Am I missing something?

Thanks.
Back to top
View user's profile Send private message
RUBn



Joined: 21 May 2007
Posts: 9

PostPosted: Wed Apr 21, 2010 4:38 pm    Post subject: Reply with quote

Thank you, shimanov!!
Solves soo many problems.

For those that integrated this in your big script, like me, you have to put the following line at the top of your script or you'll have some problems:
Code:
CoordMode, Mouse, Screen

(I don't think "return" below that is needed)
Back to top
View user's profile Send private message
RUBn



Joined: 21 May 2007
Posts: 9

PostPosted: Wed Apr 28, 2010 6:32 pm    Post subject: Re: Workaround for Trillian Astra Reply with quote

fragman wrote:
thx1200 wrote:
I found a program that doesn't like the very elegant solution by shimanov: Trillian Astra. Wheel scrolling doesn't work at all in Trillian's message windows while this script is active.

As a workaround, ....


I think trillian needs the scroll event to be send to the textbox control in chat window. With a scroll script active, it scrolls only if I have the cursor over the textbox area. ...

Confirmed! shimanov's solution doés work on Trillian Astra if you position you cursor over the chat input area (where you type your text), even if not active. (And otherwise it indeed doesn't. Unfortunate..)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group