#include <Misc.au3>
$iClicks = 0
$sTitle = "GUI"
GUICreate($sTitle)
GUISetState()
While WinExists($sTitle)
Switch GUIGetMsg()
Case -3
ExitLoop
EndSwitch
If _IsPressed(2) Then
$iClicks += 1
While _IsPressed(2)
Sleep(10)
WEnd
EndIf
WEnd
MsgBox(64, 'Title', $iClicks)