I started scouring the internet for something useful and I came upon AHK, it looked like just the thing. Took me little time to grasp the language and I started banging out all kinds of crazy non-working code. Luckily, my experience from my previous career in software development (which was ended very early by RSI--I'm sure there's irony in there somewhere) kicked in and I got some code here for you all that I'm sure at least one of you can appreciate.
This script will make any mouse (sans wheel or otherwise) have access to a middle-click and scroll wheel function! If you use the default settings, the 3rd (perhaps more accurately the 4th since the scroll wheel is usually considered the 3rd) button on my trackball can be held down while I spin the ball foreward or back to generate WheelUp and WheelDown events. As an added bonus, I'm throwing in the middle-click for free. I always used the middle button for opening links in new tabs in Firefox. To generate a middle click event, just click the trigger key down and up without moving the mouse at all.
You Can't drag and drop with the middle click, but who drags and drops with the middle button anyway? Also, it doesn't work with joystick buttons as I have it here--Joystick buttons appearantly don't generate key-up events. As you can see in the code, I use KeyDown and KeyUp hotkeys to set a variable to the state of the key. I could have eliminated the KeyDown variable in favor of GetKeyState() within the Timer function, but I thought that might hit the system too hard. Anywho, it would be easy to drop KeyDown for GetKeyState(), if you needed to use a joystick.
Don't forget to configure it before using it. Your mouse may not have "XButton"s and you might prefer to use another key or combination of keys.
Here it is:
;; ;; Emulate_Scrolling_Middle_Button.ahk ;; Author: Erik Elmore <[email protected]> ;; Version: 1.1 (Aug 16, 2005) ;; ;; Enables you to use any key with cursor movement ;; to emulate a scrolling middle button. While ;; the TriggerKey is held down, you may move the ;; mouse cursor up and down to send scroll wheel ;; events. If the cursor does not move by the ;; time the TriggerKey is released, then a middle ;; button click is generated. I wrote this for my ;; 4-button Logitech Marble Mouse (trackball), ;; which has no middle button or scroll wheel. ;; ;; Configuration ;#NoTrayIcon ;; Higher numbers mean less sensitivity esmb_Threshold = 5 ;; This key/Button activates scrolling esmb_TriggerKey = XButton1 ;; End of configuration #Persistent CoordMode, Mouse, Screen Hotkey, %esmb_TriggerKey%, esmb_TriggerKeyDown HotKey, %esmb_TriggerKey% Up, esmb_TriggerKeyUp esmb_KeyDown = n SetTimer, esmb_CheckForScrollEventAndExecute, 10 return esmb_TriggerKeyDown: esmb_Moved = n esmb_FirstIteration = y esmb_KeyDown = y MouseGetPos,, esmb_OldY return esmb_TriggerKeyUp: esmb_KeyDown = n ;; Send a middle-click if we did not scroll if esmb_Moved = n MouseClick, Middle return esmb_CheckForScrollEventAndExecute: if esmb_KeyDown = n return MouseGetPos,, esmb_NewY esmb_Distance := esmb_NewY - esmb_OldY if esmb_Distance esmb_Moved = y ;; Do not send clicks on the first iteration if esmb_FirstIteration = y esmb_FirstIteration = n else if esmb_Distance > %esmb_Threshold% { esmb_OldY := esmb_OldY + esmb_Threshold MouseClick, WheelDown } else if esmb_Distance < -%esmb_Threshold% { esmb_OldY := esmb_OldY - esmb_Threshold MouseClick, WheelUp } returnIt's my first script ever for AHK, so try to keep the criticism constructive. I'm sure I can use it.
Enjoy!
[Edit]