I've got a Logitech Marble Trackball (which is great, btw). By setting one of the extra buttons as a "middle" mouse button, when I click it, many apps (like browsers) will start "scrolling mode" so that moving the trackball will scroll up and down. Most of the time, this is sufficient, but I figure it would be way cooler if I could have several "modes" to do different things like zooming, panning, rotating (particularly in GIMP). Then when I hold CTRL, CTRL+SHIFT, or some such, it would enter a new mode, and the trackball would behave differently.

I found a couple questions similar to this that suggest using AutoHotKey, but I haven't found an example script to do this, nor can I find out to track mouse movements within AHK. Any pointers?

hotkey for scrollwheel

remedy for a no scroll wheel trackball?


  • There are some scripts if you google : autohotkey trackball – BrianA Mar 19 '12 at 6:58

After fiddling for quite a while, I came up with this script that works fairly well. Holding down CapsLock enters into "mouse wheel" mode. It's also possible to hold CapsLock+Ctrl to get alternate behavior (like zooming), depending on the app. The script needs to constantly reset the mouse position to keep it on-screen, so it hides the cursor for the duration of the mode (grab the cursor-hiding script as well).

CoordMode, Mouse, Screen

    MouseGetPos, xposinit, yposinit
    xposlast := xposinit
    yposlast := yposinit


    SetTimer, ButtonHold, 10
    KeyWait, CapsLock
    SetTimer, ButtonHold, off

    MouseMove, xposinit, yposinit, 0


        MouseGetPos, xpos, ypos

        if (ypos > yposlast) {
            MouseClick, WheelDown
        } else if (ypos < yposlast) {
            MouseClick, WheelUp

        MouseMove, xposlast, yposlast, 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.