6

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?

Thanks!

1
  • There are some scripts if you google : autohotkey trackball
    – BrianA
    Mar 19, 2012 at 6:58

1 Answer 1

5

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

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

    SystemCursor("Off")

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

    MouseMove, xposinit, yposinit, 0
    SystemCursor("On")

    Return

    ButtonHold:
        MouseGetPos, xpos, ypos

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

        MouseMove, xposlast, yposlast, 0

You must log in to answer this question.