You could compare against previous state and only execute if state has changed compared to previous state, something like this:
Code:
prevState = -1
function main()
A=reaper.JS_Mouse_GetState(-1)
reaper.defer(main)
if prevState ~= A then
if A == 5 then
reaper.ShowConsoleMsg("CMD+Click")
end
end
prevState = A
end
main()
Makes use of a global variable though, not sure if there'd be a way around it..