How to simulate multiple mouse clicks while holding the mouse button? I want my mouse to rapidly auto-click when I hold the left mouse button and to stop as soon as I release the left button. How can I do this?

I have searched for hours, I didn't find anything! Is there possibly a way to do it with AppleScript? Or if there's a free application that can do this, it's perfectly fine too.
I made a solution for you.  Its got a few pieces, it might have taken me forever to come up with, and could probably use some polishing but its pretty darn close to what you wanted.  The only thing I cannot see us being able to accomplish is holding the mouse down to do it.  I couldn't find anything that would allow us to use the mouseup to turn off our clicking loop, so I used a toggle: Click once to start our crazy clicks , and click again to stop it (I used the middle click button as my start and stop)

We are using applescript, a command line tool for OSX called MouseTools, and an application called MagicPref to assign the script to one of our mouse buttons.

once you download and extract MouseTools, it is just a batch script.  I put it and my applescripts inside the same folder (I named the folder superclicks).  Now we just need to create a loop that clicks at the current location of the mouse, and a way to break out of that loop. 

Here are the two applescript apps we make:

launch.app

global thisFile
set thisFile to (path to me)

global thisFolder
tell application "Finder" to set thisFolder to container of thisFile as text


# Function to check current state / should we should stop clicking
on checkstate()
local clickState
tell application "Finder"
    if exists file (thisFolder &amp; "STOP_CLICKING.txt") then
        set clickState to false
    else if exists file (thisFolder &amp; "CLICKING.txt") then
        set clickState to true
    else
        set clickState to null
    end if
end tell
return clickState
end checkstate

#function to update state of clicking via text files
#im sure there is a better way, but this certainly works
on togglestate()
if checkstate() is null then
    tell application "Finder" to make new file at thisFolder with properties     {name:"CLICKING.txt"}
else if checkstate() is true then
    tell application "Finder" to make new file at thisFolder with properties {name:"STOP_CLICKING.txt"}
else if checkstate() is false then
    tell application "Finder"
        delete file (thisFolder &amp; "CLICKING.txt")
        delete file (thisFolder &amp; "STOP_CLICKING.txt")
    end tell
end if
end togglestate


togglestate()
#we dont really want 3 states so we'll toggle again after a reset
if checkstate() is null then togglestate()

if checkstate() is true then
tell application "Finder"
    open (thisFolder &amp; "clicking_script")
end tell
end if


clicking_script.app

global thisFile
set thisFile to (path to me)

global thisFolder
tell application "Finder" to set thisFolder to container of thisFile as text


## Function to check current state / should we should stop clicking
on checkstate()
local clickState
tell application "Finder"
    if exists file (thisFolder &amp; "STOP_CLICKING.txt") then
        set clickState to false
    else if exists file (thisFolder &amp; "CLICKING.txt") then
        set clickState to true
    else
        set clickState to null
    end if
end tell
return clickState
end checkstate


# let the clicking begin
on crazyClick()
set x to 0
repeat until checkstate() = false or x = 1000
    do shell script ((POSIX path of thisFolder as text) &amp; "mousetools -leftClick")
    do shell script ((POSIX path of thisFolder as text) &amp; "mousetools -releaseMouse")
    set x to (x + 1)
    delay 0
end repeat
end crazyClick

crazyClick()


These two scripts need to be saved as applications. Once you have those three items in your folder all you have to do is assign launch.app as a custom application to be launched for a particular click using MagicPrefs.

When you activate the script it clicks like crazy until you activate it again, which breaks the loop by adding some empty text files to the folder. We used the text files as a simple way to have external variables.

I have zipped all the files for easy downloading.

It might not be perfect but its definitely a good start to seeing what creativeness can be accomplished with automation.