What Theo said will work, it might also be possible to use xev to get the scan code that the middle mouse click produces, and use that somewhat like he suggested above.
xev comes with every XFree86 distribution and is used to get your keyboard or mouse scancodes.
The default install location of this program is in /usr/X11R6/bin/xev. When you run this program you'll be looking at a white window with a black square in the middle. This program is used to record X11 Events such as mouse clicks, keyboard keys, etc.
Note that using xev is similar to playing an arcade game, expect it to take quite a few attempts to get the info you want--especially on a really fast computer.
I really wanted to post the output examples of the xev command and a lot of basic information about scancodes, Xmodmap, the XKeysymDB file and key press events--but the text box software would not let me do it.
Apparently it thought it was code instead of program output and said it had to be formatted with 4 spaces in front of the code--but since it wasn't code, neither of their "fix the problem" methods worked. I tried the Code link at the top of the edit box and Ctrl+K.
Sorry about that, it would have helped you lot. Next time I post I will stick to simple words and short explanations--it was entirely to time consuming and too much trouble trying to post my information.