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?