Mouse Click Counter

Hey All,

I need to create an app that counts all mouse clicks in all applications, then saves the details to a log.txt file. I found an Autohotkey script that does this when compiled into an executable for Windows PCs, but is there anyway to do this in AppleScript? The following is the Autohotkey script:

GoSub,ResetCounters
GoSub,UpdateTrayTip
Menu,Tray,NoStandard
Menu,Tray,Add,Reset,ResetCounters
Menu,Tray,Add,Exit,Exit
OnExit,LogAndExit
Exit

~LButton::L++
~MButton::M++
~RButton::R++

ResetCounters:
L=0
M=0
R=0
Return

UpdateTrayTip:
Menu,Tray,Tip,Click Counter by BikeMiken%L% left clicksn%M% middle clicks`n%R% right clicks
SetTimer,UpdateTrayTip,5000
Return

LogAndExit:
FormatTime,T,dd/MM/yyyy hh:mm:ss
FileAppend,%T% %L% left clicks, %M% middle clicks, %R% right clicks`n,Click counter.log
ExitApp

Exit:
ExitApp

Model: MacBook Pro
AppleScript: 2.0.1
Browser: Firefox 3.0.5
Operating System: Mac OS X (10.5)

Moved the topic from the Code Exchange to the OS X forum.