Toggle The Mouse Pointer Off When It's Not Moving

Started by kevin, August 20, 2012, 01:57:53 AM

Previous topic - Next topic

kevin

Toggle The  Mouse Pointer Off When It's Not Moving




PlayBASIC Code: [Select]
   ; hide mouse pointer 
mouse off

; init starting setting
MouseOffTime=Timer()+3000
MouseVisible=true

;
Do

; clear the screen to black
cls

; get the current millisecond
CurrentTime=timer()

; store the old mouse position (it's position last frame)
oldmx=mx
oldmy=my

; get the current mouse position
mx=mousex()
my=mousey()

; check if it's time to query the mouse visible state
if MouseOffTime<CurrentTime
;
MouseVisible =false

; check if the mouse has moved more than 1 along either axis
if abs(OldMx-mx) > 1 or abs(oldMy-my) >1
; if so, turn the mouse on and set it's off time to 3 second
; from now.
MouseVisible =true
MouseOffTime =CurrentTime+3000
endif

endif


; draw a circle to represent the mouse
if MouseVisible
print "Mouse Visible"
Circle Mx,My,10,true
else
print "Mouse OFF"
endif

; flip the back to front buffer
Sync

loop






Related To:

   * Check If a point is inside a box/rect region (Manual PointInBox)
   * Storing User Input In Global Types
   * Drag Rectangles/ GUI Selection