ClickThreshold = 0.2 'down and up in threshold of a second to count as a click. If down for more then threshold, we just have a hold event.
UpdateMouseInfo
PRINT LeftMouse
, MiddleMouse
, RightMouse
IF LeftMouse
AND 2 THEN leftclick
= leftclick
+ 1 IF MiddleMouse
AND 2 THEN middleclick
= middleclick
+ 1 IF RightMouse
AND 2 THEN rightclick
= rightclick
+ 1 PRINT leftclick
, middleclick
, rightclick
MouseX
= _AXIS(1) * SW
+ SW: MouseY
= _AXIS(2) * SH
+ SH
IF leftdown
THEN 'if it was down LeftMouse = 2 'clicked
LeftMouse = 0 'the mouse was just released
leftdown = 0 'timer is cleared either way
LeftMouse = 1 'the left mouse is down , timer should have already been set
leftdown
= TIMER 'set the timer to see if we have click or hold events LeftMouse = 1 'the left mouse is down
LeftMouse = 0
IF middledown
THEN 'if it was down MiddleMouse = 2 'clicked
MiddleMouse = 0 'the mouse was just released
middledown = 0 'timer is cleared either way
MiddleMouse = 1 'the middle mouse is down , timer should have already been set
middledown
= TIMER 'set the timer to see if we have click or hold events MiddleMouse = 1 'the middle mouse is down
MiddleMouse = 0
IF rightdown
THEN 'if it was down RightMouse = 2 'clicked
RightMouse = 0 'the mouse was just released
rightdown = 0 'timer is cleared either way
RightMouse = 1 'the right mouse is down , timer should have already been set
rightdown
= TIMER 'set the timer to see if we have click or hold events RightMouse = 1 'the right mouse is down
RightMouse = 0
A simple little set of code which can be easily plugged into any other program to give us a set of working mouse values without any hassles. ;)
This tracks both "click" events and just "down" (or hold) events for us, as well as giving us x/y coordinates and wheel status. A value of 1 for LeftMouse, RightMouse, MiddleMouse tells us the button is down; a value of 2 tells us the button was actually clicked with an up, down, then up in time, action.